Class BaseIoSession

    • Constructor Detail

      • BaseIoSession

        protected BaseIoSession()
    • Method Detail

      • isConnected

        public boolean isConnected()
        Description copied from interface: IoSession
        Returns true if this session is connected with remote peer.
        Specified by:
        isConnected in interface IoSession
      • isClosing

        public boolean isClosing()
        Description copied from interface: IoSession
        Returns true if and only if this session is being closed (but not disconnected yet) or is closed.
        Specified by:
        isClosing in interface IoSession
      • isScheduledForFlush

        public boolean isScheduledForFlush()
      • setScheduledForFlush

        public boolean setScheduledForFlush​(boolean flag)
      • close

        public CloseFuture close()
        Description copied from interface: IoSession
        Closes this session immediately. This operation is asynthronous. Wait for the returned CloseFuture if you want to wait for the session actually closed.
        Specified by:
        close in interface IoSession
      • close0

        protected void close0()
        Implement this method to perform real close operation. By default, this method is implemented to set the future to 'closed' immediately.
      • write

        public WriteFuture write​(java.lang.Object message)
        Description copied from interface: IoSession
        Writes the specified message to remote peer. This operation is asynchronous; IoHandler.messageSent(IoSession, Object) will be invoked when the message is actually sent to remote peer. You can also wait for the returned WriteFuture if you want to wait for the message actually written.
        Specified by:
        write in interface IoSession
      • write

        public WriteFuture write​(java.lang.Object message,
                                 java.net.SocketAddress remoteAddress)
      • write0

        protected void write0​(IoFilter.WriteRequest writeRequest)
        Implement this method to perform real write operation with the specified writeRequest. By default, this method is implemented to set the future to 'not written' immediately.
        Parameters:
        writeRequest - Write request to make
      • getAttachment

        public java.lang.Object getAttachment()
        Description copied from interface: IoSession
        Returns an attachment of this session. This method is identical with getAttribute( "" ).
        Specified by:
        getAttachment in interface IoSession
      • setAttachment

        public java.lang.Object setAttachment​(java.lang.Object attachment)
        Description copied from interface: IoSession
        Sets an attachment of this session. This method is identical with setAttribute( "", attachment ).
        Specified by:
        setAttachment in interface IoSession
        Returns:
        Old attachment. null if it is new.
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String key)
        Description copied from interface: IoSession
        Returns the value of user-defined attribute of this session.
        Specified by:
        getAttribute in interface IoSession
        Parameters:
        key - the key of the attribute
        Returns:
        null if there is no attribute with the specified key
      • setAttribute

        public java.lang.Object setAttribute​(java.lang.String key,
                                             java.lang.Object value)
        Description copied from interface: IoSession
        Sets a user-defined attribute.
        Specified by:
        setAttribute in interface IoSession
        Parameters:
        key - the key of the attribute
        value - the value of the attribute
        Returns:
        The old value of the attribute. null if it is new.
      • setAttribute

        public java.lang.Object setAttribute​(java.lang.String key)
        Description copied from interface: IoSession
        Sets a user defined attribute without a value. This is useful when you just want to put a 'mark' attribute. Its value is set to Boolean.TRUE.
        Specified by:
        setAttribute in interface IoSession
        Parameters:
        key - the key of the attribute
        Returns:
        The old value of the attribute. null if it is new.
      • removeAttribute

        public java.lang.Object removeAttribute​(java.lang.String key)
        Description copied from interface: IoSession
        Removes a user-defined attribute with the specified key.
        Specified by:
        removeAttribute in interface IoSession
        Returns:
        The old value of the attribute. null if not found.
      • containsAttribute

        public boolean containsAttribute​(java.lang.String key)
        Description copied from interface: IoSession
        Returns true if this session contains the attribute with the specified key.
        Specified by:
        containsAttribute in interface IoSession
      • getAttributeKeys

        public java.util.Set<java.lang.String> getAttributeKeys()
        Description copied from interface: IoSession
        Returns the set of keys of all user-defined attributes.
        Specified by:
        getAttributeKeys in interface IoSession
      • getIdleTime

        public int getIdleTime​(IdleStatus status)
        Description copied from interface: IoSession
        Returns idle time for the specified type of idleness in seconds.
        Specified by:
        getIdleTime in interface IoSession
      • getIdleTimeInMillis

        public long getIdleTimeInMillis​(IdleStatus status)
        Description copied from interface: IoSession
        Returns idle time for the specified type of idleness in milliseconds.
        Specified by:
        getIdleTimeInMillis in interface IoSession
      • setIdleTime

        public void setIdleTime​(IdleStatus status,
                                int idleTime)
        Description copied from interface: IoSession
        Sets idle time for the specified type of idleness in seconds.
        Specified by:
        setIdleTime in interface IoSession
      • getWriteTimeout

        public int getWriteTimeout()
        Description copied from interface: IoSession
        Returns write timeout in seconds.
        Specified by:
        getWriteTimeout in interface IoSession
      • getWriteTimeoutInMillis

        public long getWriteTimeoutInMillis()
        Description copied from interface: IoSession
        Returns write timeout in milliseconds.
        Specified by:
        getWriteTimeoutInMillis in interface IoSession
      • setWriteTimeout

        public void setWriteTimeout​(int writeTimeout)
        Description copied from interface: IoSession
        Sets write timeout in seconds.
        Specified by:
        setWriteTimeout in interface IoSession
      • updateTrafficMask

        protected abstract void updateTrafficMask()
        Signals the IoService that the TrafficMask of this session has been changed.
      • getReadBytes

        public long getReadBytes()
        Description copied from interface: IoSession
        Returns the total number of bytes which were read from this session.
        Specified by:
        getReadBytes in interface IoSession
      • getWrittenBytes

        public long getWrittenBytes()
        Description copied from interface: IoSession
        Returns the total number of bytes which were written to this session.
        Specified by:
        getWrittenBytes in interface IoSession
      • getWrittenWriteRequests

        public long getWrittenWriteRequests()
        Description copied from interface: IoSession
        Returns the total number of write requests which were written to this session.
        Specified by:
        getWrittenWriteRequests in interface IoSession
      • getReadMessages

        public long getReadMessages()
        Description copied from interface: IoSession
        Returns the total number of messages which were read and decoded from this session.
        Specified by:
        getReadMessages in interface IoSession
      • getWrittenMessages

        public long getWrittenMessages()
        Description copied from interface: IoSession
        Returns the total number of messages which were written and encoded by this session.
        Specified by:
        getWrittenMessages in interface IoSession
      • getScheduledWriteBytes

        public int getScheduledWriteBytes()
        Description copied from interface: IoSession
        Returns the number of bytes which are scheduled to be written to this session.
        Specified by:
        getScheduledWriteBytes in interface IoSession
      • getScheduledWriteRequests

        public int getScheduledWriteRequests()
        Description copied from interface: IoSession
        Returns the number of write requests which are scheduled to be written to this session.
        Specified by:
        getScheduledWriteRequests in interface IoSession
      • increaseReadBytes

        public void increaseReadBytes​(int increment)
      • increaseWrittenBytes

        public void increaseWrittenBytes​(int increment)
      • increaseReadMessages

        public void increaseReadMessages()
      • increaseWrittenMessages

        public void increaseWrittenMessages()
      • increaseScheduledWriteBytes

        public void increaseScheduledWriteBytes​(int increment)
      • increaseScheduledWriteRequests

        public void increaseScheduledWriteRequests()
      • getCreationTime

        public long getCreationTime()
        Description copied from interface: IoSession
        Returns the time in millis when this session is created.
        Specified by:
        getCreationTime in interface IoSession
      • getLastIoTime

        public long getLastIoTime()
        Description copied from interface: IoSession
        Returns the time in millis when I/O occurred lastly.
        Specified by:
        getLastIoTime in interface IoSession
      • getLastReadTime

        public long getLastReadTime()
        Description copied from interface: IoSession
        Returns the time in millis when read operation occurred lastly.
        Specified by:
        getLastReadTime in interface IoSession
      • getLastWriteTime

        public long getLastWriteTime()
        Description copied from interface: IoSession
        Returns the time in millis when write operation occurred lastly.
        Specified by:
        getLastWriteTime in interface IoSession
      • getIdleCount

        public int getIdleCount​(IdleStatus status)
        Description copied from interface: IoSession
        Returns the number of the fired continuous sessionIdle events for the specified IdleStatus.

        If sessionIdle event is fired first after some time after I/O, idleCount becomes 1. idleCount resets to 0 if any I/O occurs again, otherwise it increases to 2 and so on if sessionIdle event is fired again without any I/O between two (or more) sessionIdle events.

        Specified by:
        getIdleCount in interface IoSession
      • getLastIdleTime

        public long getLastIdleTime​(IdleStatus status)
        Description copied from interface: IoSession
        Returns the time in millis when the last sessionIdle event is fired for the specified IdleStatus.
        Specified by:
        getLastIdleTime in interface IoSession
      • increaseIdleCount

        public void increaseIdleCount​(IdleStatus status)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object