Class LiveFeedProtocolManager
java.lang.Object
com.sportradar.livedata.sdk.feed.common.LiveFeedProtocolManager
- All Implemented Interfaces:
ProtocolManager<OutgoingMessage,LiveScoutEntityBase>
public class LiveFeedProtocolManager
extends Object
implements ProtocolManager<OutgoingMessage,LiveScoutEntityBase>
A
ProtocolManager implementation used to manage protocol which connects to a live-feed-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLiveFeedProtocolManager(Protocol<IncomingMessage, OutgoingMessage> protocol, EntityMapper<IncomingMessage, LiveScoutEntityBase> entityMapper, MessageProcessor<LiveScoutEntityBase> messageProcessor, RequestProducer<OutgoingMessage> requestProducer) Initializes a new instance of theLiveFeedProtocolManagerclass -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the underlying protocolprotected voidNotifies the observer that the connection to the server was dropped.protected final voidNotifies the observer that the protocol has successfully logged in to the server.protected final voidNotifies the observer that new message was received.voidopen()Opens the underlying protocolprotected voidprocessMessage(IncomingMessage message) Processes the received messagevoidReconnects the underlying feedprotected booleansendMessage(OutgoingMessage message, boolean blocking) Sends the passedOutgoingMessageinstance to the server.voidsendMessage(String data) Sends the passed string representation of the message to the server.voidSets the listener used to observe the currentProtocolManager.
-
Field Details
-
sdklogger
TheSdkLoggerimplementation used for structured logging.
-
-
Constructor Details
-
LiveFeedProtocolManager
public LiveFeedProtocolManager(Protocol<IncomingMessage, OutgoingMessage> protocol, EntityMapper<IncomingMessage, LiveScoutEntityBase> entityMapper, MessageProcessor<LiveScoutEntityBase> messageProcessor, RequestProducer<OutgoingMessage> requestProducer) Initializes a new instance of theLiveFeedProtocolManagerclass- Parameters:
protocol- TheProtocolimplementation used to communicate with the target feed.entityMapper- TheEntityMapperimplementation used to map received messages to feed entities.messageProcessor- TheMessageProcessorused to process incoming messagesrequestProducer- TheRequestProducerimplementation which produces message to be send to the server.
-
-
Method Details
-
close
public void close()Closes the underlying protocol- Specified by:
closein interfaceProtocolManager<OutgoingMessage,LiveScoutEntityBase>
-
open
public void open()Opens the underlying protocol- Specified by:
openin interfaceProtocolManager<OutgoingMessage,LiveScoutEntityBase>
-
reconnect
public void reconnect()Description copied from interface:ProtocolManagerReconnects the underlying feed- Specified by:
reconnectin interfaceProtocolManager<OutgoingMessage,LiveScoutEntityBase>
-
sendMessage
Sends the passed string representation of the message to the server.- Specified by:
sendMessagein interfaceProtocolManager<OutgoingMessage,LiveScoutEntityBase> - Parameters:
data- - TheStringto be send to the server.
-
setListener
Sets the listener used to observe the currentProtocolManager.- Specified by:
setListenerin interfaceProtocolManager<OutgoingMessage,LiveScoutEntityBase> - Parameters:
listener- TheProtocolManagerListenerused to observe theProtocolManager
-
notifyOnDisconnected
protected void notifyOnDisconnected()Notifies the observer that the connection to the server was dropped. -
notifyOnLoggedIn
protected final void notifyOnLoggedIn()Notifies the observer that the protocol has successfully logged in to the server. -
notifyOnMessageReceived
Notifies the observer that new message was received.- Parameters:
message- TheLiveScoutEntityBasederived instance representing the received message.
-
processMessage
Processes the received message- Parameters:
message- TheIncomingMessagerepresenting the received message.
-
sendMessage
Sends the passedOutgoingMessageinstance to the server.- Parameters:
message- theOutgoingMessageinstance to be send to the server.blocking- mark if request must be blocking.- Returns:
- true if success.
- Throws:
IllegalArgumentException- themessageis a null reference.IllegalStateException- the message cannot be send at this time.
-