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 Detail

      • start

        void start()
        Starts the protocol - i.e. enables(starts) the communication with the server.
        Throws:
        IllegalStateException - The protocol is already started.
      • reconnect

        void reconnect()
        Reconnects the underlying feed
      • isStarted

        boolean 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.
      • sendMessage

        boolean sendMessage​(O message,
                            boolean blocking)
                     throws MessageException,
                            ProtocolException
        Sends the passed message instance to the server.
        Parameters:
        message - The message derived from OutgoingMessage to 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.
      • stop

        void stop()
        Stops the protocol - i.e. disables the communication with the server.
        Throws:
        IllegalStateException - The protocol is already stopped.