Class AbstractNioSession

    • Field Detail

      • selectableChannel

        protected java.nio.channels.SelectableChannel selectableChannel
    • Constructor Detail

      • AbstractNioSession

        public AbstractNioSession​(NioSessionConfig sessionConfig)
    • Method Detail

      • channel

        public java.nio.channels.SelectableChannel channel()
        Description copied from interface: NioSession
        return the channel for this connection
        Specified by:
        channel in interface NioSession
        Returns:
      • enableRead

        public final void enableRead​(java.nio.channels.Selector selector)
        Description copied from interface: NioSession
        Enable read event
        Specified by:
        enableRead in interface NioSession
      • interestRead

        private void interestRead​(java.nio.channels.SelectionKey key)
      • getLocalAddress

        public java.net.InetAddress getLocalAddress()
        Specified by:
        getLocalAddress in interface Session
      • writeToChannel

        protected abstract java.lang.Object writeToChannel​(WriteMessage msg)
                                                    throws java.nio.channels.ClosedChannelException,
                                                           java.io.IOException
        Throws:
        java.nio.channels.ClosedChannelException
        java.io.IOException
      • onWrite

        protected void onWrite​(java.nio.channels.SelectionKey key)
      • enableWrite

        public final void enableWrite​(java.nio.channels.Selector selector)
        Description copied from interface: NioSession
        Enable write event
        Specified by:
        enableWrite in interface NioSession
      • interestWrite

        private void interestWrite​(java.nio.channels.SelectionKey key)
      • onRead

        protected void onRead​(java.nio.channels.SelectionKey key)
      • readFromBuffer

        protected abstract void readFromBuffer()
      • closeChannel

        protected void closeChannel()
                             throws java.io.IOException
        Specified by:
        closeChannel in class AbstractSession
        Throws:
        java.io.IOException
      • unregisterChannel

        protected final void unregisterChannel()
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • registerSession

        protected final void registerSession()
      • unregisterSession

        protected void unregisterSession()
      • schduleWriteMessage

        protected boolean schduleWriteMessage​(WriteMessage writeMessage)
      • flush

        public void flush()
        Description copied from interface: Session
        Flush the write queue,this method may be no effect if OP_WRITE is running.
        Specified by:
        flush in interface Session
      • flush0

        protected final void flush0()
      • doRealWrite

        protected final long doRealWrite​(java.nio.channels.SelectableChannel channel,
                                         IoBuffer buffer)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • onEvent

        public final void onEvent​(EventType event,
                                  java.nio.channels.Selector selector)
        �ɷ�IO�¼�
        Specified by:
        onEvent in interface NioSession