Interface AlpacaWebsocketInterface<L extends AlpacaWebsocketMessageListener<?,?>>
- Type Parameters:
L
- theAlpacaWebsocketMessageListener
type parameter
- All Known Subinterfaces:
MarketDataWebsocketInterface
,StreamingWebsocketInterface
- All Known Implementing Classes:
AlpacaWebsocket
,MarketDataWebsocket
,StreamingWebsocket
public interface AlpacaWebsocketInterface<L extends AlpacaWebsocketMessageListener<?,?>>
AlpacaWebsocketInterface
defines an interface for Alpaca websockets.-
Method Summary
Modifier and Type Method Description void
connect()
Connects this Websocket.void
disconnect()
Disconnects this Websocket.Future<Boolean>
getAuthorizationFuture()
boolean
isAuthenticated()
Returns true if this websocket is authenticated.boolean
isConnected()
Returns true if this websocket is connected.default boolean
isValid()
True ifisConnected()
andisAuthenticated()
.void
setListener(L listener)
Sets theAlpacaWebsocketMessageListener
for thisAlpacaWebsocketInterface
.default boolean
waitForAuthorization(long timeout, TimeUnit unit)
Waits forgetAuthorizationFuture()
to complete and returns its value, except whentimeout
time has elapsed, then this will returnfalse
.
-
Method Details
-
connect
void connect()Connects this Websocket. -
disconnect
void disconnect()Disconnects this Websocket. -
isConnected
boolean isConnected()Returns true if this websocket is connected.- Returns:
- a boolean
-
isAuthenticated
boolean isAuthenticated()Returns true if this websocket is authenticated.- Returns:
- a boolean
-
isValid
default boolean isValid()True ifisConnected()
andisAuthenticated()
.- Returns:
- a boolean
-
getAuthorizationFuture
Gets aBoolean
Future
that completes when an authentication message that is received after a new websocket connection indicates successful authentication.
Note that if thisAlpacaWebsocketInterface
is already authorized, the returnedFuture
will likely never complete. -
waitForAuthorization
Waits forgetAuthorizationFuture()
to complete and returns its value, except whentimeout
time has elapsed, then this will returnfalse
.- Parameters:
timeout
- the timeout timeunit
- the timeoutTimeUnit
- Returns:
- a boolean
-
setListener
Sets theAlpacaWebsocketMessageListener
for thisAlpacaWebsocketInterface
.- Parameters:
listener
- theAlpacaWebsocketMessageListener
-