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>
AProtocolManager
implementation used to manage protocol which connects to a live-feed
-
-
Constructor Summary
Constructors Constructor Description LiveFeedProtocolManager(Protocol<IncomingMessage,OutgoingMessage> protocol, EntityMapper<IncomingMessage,LiveScoutEntityBase> entityMapper, MessageProcessor<LiveScoutEntityBase> messageProcessor, RequestProducer<OutgoingMessage> requestProducer)
Initializes a new instance of theLiveFeedProtocolManager
class
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the underlying protocolprotected void
notifyOnDisconnected()
Notifies the observer that the connection to the server was dropped.protected void
notifyOnLoggedIn()
Notifies the observer that the protocol has successfully logged in to the server.protected void
notifyOnMessageReceived(LiveScoutEntityBase message)
Notifies the observer that new message was received.void
open()
Opens the underlying protocolprotected void
processMessage(IncomingMessage message)
Processes the received messagevoid
reconnect()
Reconnects the underlying feedprotected boolean
sendMessage(OutgoingMessage message, boolean blocking)
Sends the passedOutgoingMessage
instance to the server.void
sendMessage(String data)
Sends the passed string representation of the message to the server.void
setListener(ProtocolManagerListener<LiveScoutEntityBase> listener)
Sets the listener used to observe the currentProtocolManager
.
-
-
-
Constructor Detail
-
LiveFeedProtocolManager
public LiveFeedProtocolManager(Protocol<IncomingMessage,OutgoingMessage> protocol, EntityMapper<IncomingMessage,LiveScoutEntityBase> entityMapper, MessageProcessor<LiveScoutEntityBase> messageProcessor, RequestProducer<OutgoingMessage> requestProducer)
Initializes a new instance of theLiveFeedProtocolManager
class- Parameters:
protocol
- TheProtocol
implementation used to communicate with the target feed.entityMapper
- TheEntityMapper
implementation used to map received messages to feed entities.messageProcessor
- TheMessageProcessor
used to process incoming messagesrequestProducer
- TheRequestProducer
implementation which produces message to be send to the server.
-
-
Method Detail
-
close
public void close()
Closes the underlying protocol- Specified by:
close
in interfaceProtocolManager<OutgoingMessage,LiveScoutEntityBase>
-
open
public void open()
Opens the underlying protocol- Specified by:
open
in interfaceProtocolManager<OutgoingMessage,LiveScoutEntityBase>
-
reconnect
public void reconnect()
Description copied from interface:ProtocolManager
Reconnects the underlying feed- Specified by:
reconnect
in interfaceProtocolManager<OutgoingMessage,LiveScoutEntityBase>
-
sendMessage
public void sendMessage(String data)
Sends the passed string representation of the message to the server.- Specified by:
sendMessage
in interfaceProtocolManager<OutgoingMessage,LiveScoutEntityBase>
- Parameters:
data
- - TheString
to be send to the server.
-
setListener
public void setListener(ProtocolManagerListener<LiveScoutEntityBase> listener)
Sets the listener used to observe the currentProtocolManager
.- Specified by:
setListener
in interfaceProtocolManager<OutgoingMessage,LiveScoutEntityBase>
- Parameters:
listener
- TheProtocolManagerListener
used 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
protected final void notifyOnMessageReceived(LiveScoutEntityBase message)
Notifies the observer that new message was received.- Parameters:
message
- TheLiveScoutEntityBase
derived instance representing the received message.
-
processMessage
protected void processMessage(IncomingMessage message)
Processes the received message- Parameters:
message
- TheIncomingMessage
representing the received message.
-
sendMessage
protected boolean sendMessage(OutgoingMessage message, boolean blocking)
Sends the passedOutgoingMessage
instance to the server.- Parameters:
message
- theOutgoingMessage
instance to be send to the server.blocking
- mark if request must be blocking.- Returns:
- true if success.
- Throws:
IllegalArgumentException
- themessage
is a null reference.IllegalStateException
- the message cannot be send at this time.
-
-