Class MessagesNode<S extends NetSession>

    • Constructor Detail

      • MessagesNode

        public MessagesNode​(java.lang.String host,
                            java.lang.Integer port)
      • MessagesNode

        public MessagesNode​(java.lang.String host,
                            java.lang.Integer port,
                            Cryptography cryptography)
    • Method Detail

      • isEncrypted

        public boolean isEncrypted()
        Returns true if the server use a encrypted protocol and false in the otherwise
        Returns:
        Is encrypted or no.
      • send

        public final void send​(Message message)
                        throws java.io.IOException
        Send a message to the server.
        Parameters:
        message - Message instance.
        Throws:
        java.io.IOException - Io Exception
      • waitForConnect

        public final boolean waitForConnect()
        Wait until the node is connected with the server.
        Returns:
        Connection status, if the result is true then the node connection was successful but if the response is false the something is not work.
      • isConnected

        public final boolean isConnected()
        This method return the connected status of the node.
        Returns:
        Returns true if the node is connected and false in the otherwise
      • encrypt

        protected EncryptedMessage encrypt​(Message message)
        This method must encrypt the message and create an instance of EncryptedMessage wrapping the original message.
        Parameters:
        message - Original message.
        Returns:
        Encrypted message.
      • decrypt

        protected Message decrypt​(EncryptedMessage encryptedMessage)
        This method must decrypt the encrypted message and returns the original message decrypted.
        Parameters:
        encryptedMessage - Incoming encrypted message.
        Returns:
        Original message decrypted.
      • onRead

        protected abstract void onRead​(S session,
                                       Message incomingMessage)
        This method is called when there are a complete message into the buffer.
        Parameters:
        session - Net session.
        incomingMessage - Incoming message.