Class LiveFeedProtocol
java.lang.Object
com.sportradar.livedata.sdk.proto.common.ProtocolBase<IncomingMessage,OutgoingMessage>
com.sportradar.livedata.sdk.proto.LiveFeedProtocol
- All Implemented Interfaces:
Protocol<IncomingMessage,OutgoingMessage>
A
Protocol implementation used to connect to the live-feed.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.joda.time.DurationWhen having to wait longer than that amount of time for logging-in, just disconnect.Fields inherited from class com.sportradar.livedata.sdk.proto.common.ProtocolBase
gateway, isStarted, listener, messageParser, sdkLogger -
Constructor Summary
ConstructorsConstructorDescriptionLiveFeedProtocol(Gateway gateway, MessageParser<IncomingMessage> messageParser, MessageWriter<OutgoingMessage> messageWriter, RateLimiter rateLimiter, OutgoingMessageInspector<OutgoingMessage> outgoingMessageInspector, AuthMessageProvider authMessageProvider) Initializes a new instance of theLiveFeedProtocolclass. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidNotifies the observer that the currentLiveFeedProtocolhas disconnected.protected voidNotifies the observer that the currentLiveFeedProtocolhas logged in.protected voidInvoked by the observedGatewayinstance when it establishes a connection to the server.protected voidInvoked when the internally usedGatewaydrops connection to the remote host.protected voidonMessageParsed(IncomingMessage message) Invoked when the observedMessageParserparsed data which represented a whole message.booleansendMessage(OutgoingMessage message, boolean blocking) Sends the passedOutgoingMessageinstance to the server.voidsendMessage(String data) Sends the passed data to the server as is.voidstop()Stops the protocol - i.e.Methods inherited from class com.sportradar.livedata.sdk.proto.common.ProtocolBase
connect, isStarted, notifyOnEvent, notifyOnMessageReceived, onGatewayDataReceived, onGatewayError, reconnect, setDependencyListeners, setListener, start
-
Field Details
-
DISCONNECT_WHEN_HAVING_TO_WAIT_LONGER_THAN
protected final org.joda.time.Duration DISCONNECT_WHEN_HAVING_TO_WAIT_LONGER_THANWhen having to wait longer than that amount of time for logging-in, just disconnect.
-
-
Constructor Details
-
LiveFeedProtocol
public LiveFeedProtocol(Gateway gateway, MessageParser<IncomingMessage> messageParser, MessageWriter<OutgoingMessage> messageWriter, RateLimiter rateLimiter, OutgoingMessageInspector<OutgoingMessage> outgoingMessageInspector, AuthMessageProvider authMessageProvider) Initializes a new instance of theLiveFeedProtocolclass.- Parameters:
gateway- TheGatewayimplementation used to establish a connection to the live-odds server.messageParser- TheMessageParserimplementation used to constructIncomingMessageinstances from data received from the server.messageWriter- Theused to write messages to byte[].rateLimiter- TheRateLimiterimplementation used to rate-limit send messagesoutgoingMessageInspector- TheOutgoingMessageInspectorimplementation used to inspect send messages.authMessageProvider- The provider of authentication messages such as login and logout.
-
-
Method Details
-
sendMessage
public boolean sendMessage(OutgoingMessage message, boolean blocking) throws MessageException, ProtocolException Sends the passedOutgoingMessageinstance to the server.- Parameters:
message- The message derived fromOutgoingMessageto be send to the server.blocking- true if request must be blocking.- Returns:
- true if success.
- Throws:
MessageException- An error occurred while writing the message to byte array.ProtocolException- thrown when an un-expected situation is encountered.
-
sendMessage
Sends the passed data to the server as is.- Parameters:
data- data to be sent.- Throws:
MessageException- An error occurred while writing the message to byte array.ProtocolException- thrown when an un-expected situation is encountered.
-
stop
public void stop()Stops the protocol - i.e. disables the communication with the server.- Specified by:
stopin interfaceProtocol<IncomingMessage,OutgoingMessage> - Overrides:
stopin classProtocolBase<IncomingMessage,OutgoingMessage>
-
onGatewayConnected
protected void onGatewayConnected()Invoked by the observedGatewayinstance when it establishes a connection to the server.- Overrides:
onGatewayConnectedin classProtocolBase<IncomingMessage,OutgoingMessage>
-
onGatewayDisconnected
protected void onGatewayDisconnected()Invoked when the internally usedGatewaydrops connection to the remote host.- Overrides:
onGatewayDisconnectedin classProtocolBase<IncomingMessage,OutgoingMessage>
-
onMessageParsed
Invoked when the observedMessageParserparsed data which represented a whole message.- Overrides:
onMessageParsedin classProtocolBase<IncomingMessage,OutgoingMessage> - Parameters:
message- Message constructed from the received data.
-
notifyOnDisconnected
protected void notifyOnDisconnected()Notifies the observer that the currentLiveFeedProtocolhas disconnected. -
notifyOnLoggedIn
protected void notifyOnLoggedIn()Notifies the observer that the currentLiveFeedProtocolhas logged in.
-