Interface Protocol<I extends IncomingMessage,O extends OutgoingMessage> 
- Type Parameters:
- I- Specifies the type of the messages received by the protocol
- O- Specifies the type of the message send by the protocol
- All Known Implementing Classes:
- LiveFeedProtocol,- ProtocolBase
public interface Protocol<I extends IncomingMessage,O extends OutgoingMessage> 
Represents a protocol which knows how to properly communicate with the server
- Author:
- uros.bregar
- 
Method SummaryModifier and TypeMethodDescriptionbooleanGets the value indicating whether the protocol is started - i.e if the communication with server is enabled.voidReconnects the underlying feedvoidsendMessage(String data) Sends the passed data to the server as is.booleansendMessage(O message, boolean blocking) Sends the passedmessageinstance to the server.voidsetListener(ProtocolListener<I> listener) Sets theProtocolListenerused to observe the currentProtocol.voidstart()Starts the protocol - i.e.voidstop()Stops the protocol - i.e.
- 
Method Details- 
startvoid start()Starts the protocol - i.e. enables(starts) the communication with the server.- Throws:
- IllegalStateException- The protocol is already started.
 
- 
reconnectvoid reconnect()Reconnects the underlying feed
- 
isStartedboolean isStarted()Gets the value indicating whether the protocol is started - i.e if the communication with server is enabled.- Returns:
- True if protocol is started. False otherwise.
 
- 
setListenerSets theProtocolListenerused to observe the currentProtocol.- Parameters:
- listener- the- ProtocolListenerused to observe the current- Protocolor a null reference.
 
- 
sendMessageSends the passedmessageinstance to the server.- Parameters:
- message- The message derived from- OutgoingMessageto 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.
 
- 
sendMessageSends 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.
 
- 
stopvoid stop()Stops the protocol - i.e. disables the communication with the server.- Throws:
- IllegalStateException- The protocol is already stopped.
 
 
-