Class NettyConnection

    • Field Detail

      • KEY_CONNECTION

        public static final io.netty.util.AttributeKey<Connection> KEY_CONNECTION
        Save this connection itself to its channel. In case of Datagram channel, we use Connection.__address as a key for the current connection
      • __remote

        protected java.net.InetSocketAddress __remote
        Save the client's address, in Datagram connection it is used for saving as a key of the Connection.getUsername()
    • Method Detail

      • send

        public void send​(TObject message)
        Description copied from class: Connection
        Send a message to the client
        Specified by:
        send in class Connection
        Parameters:
        message - the message content, see TObject
      • close

        public void close()
        Description copied from class: Connection
        Close a "connection" between a client with the server
        Specified by:
        close in class Connection
      • getThis

        public Connection getThis()
        Description copied from class: Connection
        Retrieve this connection itself by channel
        Specified by:
        getThis in class Connection
        Returns:
        the current connection
      • setThis

        public void setThis()
        Description copied from class: Connection
        Set this connection into current channel Note: Set value for one key. You can set your custom data to one connection to quick access. These keys and values should be saved to channel (which is defined by NIO mechanism)
        Specified by:
        setThis in class Connection
      • removeThis

        public void removeThis()
        Description copied from class: Connection
        Remove the connection object from channel cache
        Specified by:
        removeThis in class Connection
      • setRemote

        public void setRemote​(java.net.InetSocketAddress remote)
        Description copied from class: Connection
        Set the current address for your "connection" (only need for Socket type)
        Specified by:
        setRemote in class Connection
        Parameters:
        remote - , see InetSocketAddress
      • clean

        public void clean()
        Description copied from class: Connection
        Delete the keys which are used to identify a player in one "connection". This method need to be implemented when the "connection" type is Socket or WebSocket
        Specified by:
        clean in class Connection