org.apache.mina.core.session

## Class AbstractIoSession

- java.lang.Object
- - org.apache.mina.core.session.AbstractIoSession

- All Implemented Interfaces:
    IoSession
  Direct Known Subclasses:
    AprSession, DummySession, NioSession

      public abstract class AbstractIoSession
      extends Object
      implements IoSession

  Base implementation of `IoSession`.
  Author:
    Apache MINA Project

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected IoSessionConfig` | `config` The session config

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractIoSession(IoService service)` TODO Add method documentation

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `CloseFuture` | `close()` Closes this session after all queued write requests are flushed.
    `CloseFuture` | `close(boolean rightNow)` Closes this session immediately or after all queued write requests are flushed.
    `boolean` | `containsAttribute(Object key)` Returns `true` if this session contains the attribute with the specified `key`.
    `void` | `decreaseReadBufferSize()` TODO Add method documentation
    `void` | `decreaseScheduledBytesAndMessages(WriteRequest request)` TODO Add method documentation
    `boolean` | `equals(Object o)` TODO This is a ridiculous implementation.
    `Object` | `getAttachment()` Returns an attachment of this session.
    `Object` | `getAttribute(Object key)` Returns the value of the user-defined attribute of this session.
    `Object` | `getAttribute(Object key, Object defaultValue)` Returns the value of user defined attribute associated with the specified key.
    `Set<Object>` | `getAttributeKeys()` Returns the set of keys of all user-defined attributes.
    `IoSessionAttributeMap` | `getAttributeMap()` TODO Add method documentation
    `int` | `getBothIdleCount()` Returns the number of the fired continuous `sessionIdle` events for `IdleStatus.BOTH_IDLE`.
    `CloseFuture` | `getCloseFuture()` Returns the `CloseFuture` of this session.
    `IoSessionConfig` | `getConfig()`
    `long` | `getCreationTime()`
    `Object` | `getCurrentWriteMessage()` Returns the message which is being written by `IoService`.
    `WriteRequest` | `getCurrentWriteRequest()` Returns the `WriteRequest` which is being processed by `IoService`.
    `IoHandler` | `getHandler()`
    `long` | `getId()` We use an AtomicLong to guarantee that the session ID are unique.
    `int` | `getIdleCount(IdleStatus status)` Returns the number of the fired continuous `sessionIdle` events for the specified `IdleStatus`.
    `long` | `getLastBothIdleTime()` Returns the time in milliseconds when the last `sessionIdle` event is fired for `IdleStatus.BOTH_IDLE`.
    `long` | `getLastIdleTime(IdleStatus status)` Returns the time in milliseconds when the last `sessionIdle` event is fired for the specified `IdleStatus`.
    `long` | `getLastIoTime()` Returns the time in millis when I/O occurred lastly.
    `long` | `getLastReaderIdleTime()` Returns the time in milliseconds when the last `sessionIdle` event is fired for `IdleStatus.READER_IDLE`.
    `long` | `getLastReadTime()` Returns the time in millis when read operation occurred lastly.
    `long` | `getLastWriterIdleTime()` Returns the time in milliseconds when the last `sessionIdle` event is fired for `IdleStatus.WRITER_IDLE`.
    `long` | `getLastWriteTime()` Returns the time in millis when write operation occurred lastly.
    `abstract IoProcessor` | `getProcessor()`
    `long` | `getReadBytes()` Returns the total number of bytes which were read from this session.
    `double` | `getReadBytesThroughput()` Returns the number of read bytes per second.
    `int` | `getReaderIdleCount()` Returns the number of the fired continuous `sessionIdle` events for `IdleStatus.READER_IDLE`.
    `long` | `getReadMessages()` Returns the total number of messages which were read and decoded from this session.
    `double` | `getReadMessagesThroughput()` Returns the number of read messages per second.
    `long` | `getScheduledWriteBytes()` Returns the number of bytes which are scheduled to be written to this session.
    `int` | `getScheduledWriteMessages()` Returns the number of messages which are scheduled to be written to this session.
    `IoService` | `getService()`
    `SocketAddress` | `getServiceAddress()` Returns the socket address of the `IoService` listens to to manage this session.
    `WriteRequestQueue` | `getWriteRequestQueue()` TODO Add method documentation
    `int` | `getWriterIdleCount()` Returns the number of the fired continuous `sessionIdle` events for `IdleStatus.WRITER_IDLE`.
    `long` | `getWrittenBytes()` Returns the total number of bytes which were written to this session.
    `double` | `getWrittenBytesThroughput()` Returns the number of written bytes per second.
    `long` | `getWrittenMessages()` Returns the total number of messages which were written and encoded by this session.
    `double` | `getWrittenMessagesThroughput()` Returns the number of written messages per second.
    `int` | `hashCode()`
    `void` | `increaseIdleCount(IdleStatus status, long currentTime)` TODO Add method documentation
    `void` | `increaseReadBufferSize()` TODO Add method documentation
    `void` | `increaseReadBytes(long increment, long currentTime)` TODO Add method documentation
    `void` | `increaseReadMessages(long currentTime)` TODO Add method documentation
    `void` | `increaseScheduledWriteBytes(int increment)` TODO Add method documentation
    `void` | `increaseScheduledWriteMessages()` TODO Add method documentation
    `void` | `increaseWrittenBytes(int increment, long currentTime)` TODO Add method documentation
    `void` | `increaseWrittenMessages(WriteRequest request, long currentTime)` TODO Add method documentation
    `boolean` | `isBothIdle()` Returns `true` if this session is `IdleStatus.BOTH_IDLE`.
    `boolean` | `isClosing()` Returns `true if and only if this session is being closed (but not disconnected yet) or is closed.`
    `boolean` | `isConnected()` Returns `true` if this session is connected with remote peer.
    `boolean` | `isIdle(IdleStatus status)` Returns `true` if this session is idle for the specified `IdleStatus`.
    `boolean` | `isReaderIdle()` Returns `true` if this session is `IdleStatus.READER_IDLE`.
    `boolean` | `isReadSuspended()` Is read operation is suspended for this session.
    `boolean` | `isScheduledForFlush()` Tells if the session is scheduled for flushed
    `boolean` | `isWriterIdle()` Returns `true` if this session is `IdleStatus.WRITER_IDLE`.
    `boolean` | `isWriteSuspended()` Is write operation is suspended for this session.
    `static void` | `notifyIdleness(Iterator<? extends IoSession> sessions, long currentTime)` Fires a `IoEventType.SESSION_IDLE` event to any applicable sessions in the specified collection.
    `static void` | `notifyIdleSession(IoSession session, long currentTime)` Fires a `IoEventType.SESSION_IDLE` event if applicable for the specified `session`.
    `void` | `offerClosedReadFuture()` TODO Add method documentation
    `void` | `offerFailedReadFuture(Throwable exception)` TODO Add method documentation
    `void` | `offerReadFuture(Object message)` TODO Add method documentation
    `ReadFuture` | `read()` TODO This javadoc is wrong.
    `Object` | `removeAttribute(Object key)` Removes a user-defined attribute with the specified key.
    `boolean` | `removeAttribute(Object key, Object value)` Removes a user defined attribute with the specified key if the current attribute value is equal to the specified value.
    `boolean` | `replaceAttribute(Object key, Object oldValue, Object newValue)` Replaces a user defined attribute with the specified key if the value of the attribute is equals to the specified old value.
    `void` | `resumeRead()` Resumes read operations for this session.
    `void` | `resumeWrite()` Resumes write operations for this session.
    `void` | `scheduledForFlush()` Schedule the session for flushed
    `Object` | `setAttachment(Object attachment)` Sets an attachment of this session.
    `Object` | `setAttribute(Object key)` Sets a user defined attribute without a value.
    `Object` | `setAttribute(Object key, Object value)` Sets a user-defined attribute.
    `Object` | `setAttributeIfAbsent(Object key)` Sets a user defined attribute without a value if the attribute with the specified key is not set yet.
    `Object` | `setAttributeIfAbsent(Object key, Object value)` Sets a user defined attribute if the attribute with the specified key is not set yet.
    `void` | `setAttributeMap(IoSessionAttributeMap attributes)` TODO Add method documentation
    `void` | `setCurrentWriteRequest(WriteRequest currentWriteRequest)` TODO setWriteRequestQueue.
    `boolean` | `setScheduledForFlush(boolean schedule)` Set the scheduledForFLush flag.
    `protected void` | `setScheduledWriteBytes(int byteCount)` TODO Add method documentation
    `protected void` | `setScheduledWriteMessages(int messages)` TODO Add method documentation
    `void` | `setWriteRequestQueue(WriteRequestQueue writeRequestQueue)` Create a new close aware write queue, based on the given write queue.
    `void` | `suspendRead()` Suspends read operations for this session.
    `void` | `suspendWrite()` Suspends write operations for this session.
    `String` | `toString()`
    `void` | `unscheduledForFlush()` Change the session's status : it's not anymore scheduled for flush
    `void` | `updateThroughput(long currentTime, boolean force)` Update all statistical properties related with throughput assuming the specified time is the current time.
    `WriteFuture` | `write(Object message)` Writes the specified `message` to remote peer.
    `WriteFuture` | `write(Object message, SocketAddress remoteAddress)` (Optional) Writes the specified `message` to the specified `destination`.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.mina.core.session.IoSession

      `getFilterChain, getLocalAddress, getRemoteAddress, getTransportMetadata`

- - ### Field Detail

    - #### config

          protected IoSessionConfig config

      The session config

  - ### Constructor Detail

    - #### AbstractIoSession

          protected AbstractIoSession(IoService service)

      TODO Add method documentation

  - ### Method Detail

    - #### getId

          public final long getId()

      We use an AtomicLong to guarantee that the session ID are unique.
      Specified by:
        `getId` in interface `IoSession`
      Returns:
        a unique identifier for this session. Every session has its own ID which is different from each other. TODO : The way it's implemented does not guarantee that the contract is respected. It uses the HashCode() method which don't guarantee the key unicity.

    - #### getProcessor

          public abstract IoProcessor getProcessor()

      Returns:
        The associated IoProcessor for this session

    - #### isConnected

          public final boolean isConnected()

      Returns `true` if this session is connected with remote peer.
      Specified by:
        `isConnected` in interface `IoSession`

    - #### isClosing

          public final boolean isClosing()

      Returns `true if and only if this session is being closed (but not disconnected yet) or is closed.`
      Specified by:
        `isClosing` in interface `IoSession`

    - #### getCloseFuture

          public final CloseFuture getCloseFuture()

      Returns the `CloseFuture` of this session. This method returns the same instance whenever user calls it.
      Specified by:
        `getCloseFuture` in interface `IoSession`

    - #### isScheduledForFlush

          public final boolean isScheduledForFlush()

      Tells if the session is scheduled for flushed
      Parameters:
        `true` - if the session is scheduled for flush

    - #### scheduledForFlush

          public final void scheduledForFlush()

      Schedule the session for flushed

    - #### unscheduledForFlush

          public final void unscheduledForFlush()

      Change the session's status : it's not anymore scheduled for flush

    - #### setScheduledForFlush

          public final boolean setScheduledForFlush(boolean schedule)

      Set the scheduledForFLush flag. As we may have concurrent access to this flag, we compare and set it in one call.
      Parameters:
        `schedule` - the new value to set if not already set.
      Returns:
        true if the session flag has been set, and if it wasn't set already.

    - #### close

          public final CloseFuture close(boolean rightNow)

      Closes this session immediately or after all queued write requests are flushed. This operation is asynchronous. Wait for the returned `CloseFuture` if you want to wait for the session actually closed.
      Specified by:
        `close` in interface `IoSession`
      Parameters:
        `rightNow` - `true` to close this session immediately (i.e. `IoSession.close()`). The pending write requests will simply be discarded. `false` to close this session after all queued write requests are flushed (i.e. `#closeOnFlush()`).

    - #### close

          public final CloseFuture close()

      Closes this session after all queued write requests are flushed. This operation is asynchronous. Wait for the returned `CloseFuture` if you want to wait for the session actually closed.
      Specified by:
        `close` in interface `IoSession`

    - #### getHandler

          public IoHandler getHandler()

      Specified by:
        `getHandler` in interface `IoSession`
      Returns:
        the `IoHandler` which handles this session.

    - #### getConfig

          public IoSessionConfig getConfig()

      Specified by:
        `getConfig` in interface `IoSession`
      Returns:
        the configuration of this session.

    - #### read

          public final ReadFuture read()

      TODO This javadoc is wrong. The return tag should be short.
      Specified by:
        `read` in interface `IoSession`
      Returns:
        a `ReadFuture` which is notified when a new message is received, the connection is closed or an exception is caught. This operation is especially useful when you implement a client application. TODO : Describe here how we enable this feature. However, please note that this operation is disabled by default and throw `IllegalStateException` because all received events must be queued somewhere to support this operation, possibly leading to memory leak. This means you have to keep calling `IoSession.read()` once you enabled this operation. To enable this operation, please call `IoSessionConfig.setUseReadOperation(boolean)` with `true`.

    - #### offerReadFuture

          public final void offerReadFuture(Object message)

      TODO Add method documentation

    - #### offerFailedReadFuture

          public final void offerFailedReadFuture(Throwable exception)

      TODO Add method documentation

    - #### offerClosedReadFuture

          public final void offerClosedReadFuture()

      TODO Add method documentation

    - #### write

          public WriteFuture write(Object message)

      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(Object message,
                          SocketAddress remoteAddress)

      (Optional) Writes the specified `message` to the specified `destination`. 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.

      When you implement a client that receives a broadcast message from a server such as DHCP server, the client might need to send a response message for the broadcast message the server sent. Because the remote address of the session is not the address of the server in case of broadcasting, there should be a way to specify the destination when you write the response message. This interface provides `IoSession.write(Object, SocketAddress)` method so you can specify the destination.

      Specified by:
        `write` in interface `IoSession`
        `remoteAddress` - `null` if you want the message sent to the default remote address

    - #### getAttachment

          public final Object getAttachment()

      Returns an attachment of this session. This method is identical with `getAttribute( "" )`.
      Specified by:
        `getAttachment` in interface `IoSession`

    - #### setAttachment

          public final Object setAttachment(Object attachment)

      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 final Object getAttribute(Object key)

      Returns the value of the 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

    - #### getAttribute

          public final Object getAttribute(Object key,
                            Object defaultValue)

      Returns the value of user defined attribute associated with the specified key. If there's no such attribute, the specified default value is associated with the specified key, and the default value is returned. This method is same with the following code except that the operation is performed atomically.

           if (containsAttribute(key)) {
               return getAttribute(key);
           } else {
               setAttribute(key, defaultValue);
               return defaultValue;
           }

      Specified by:
        `getAttribute` in interface `IoSession`

    - #### setAttribute

          public final Object setAttribute(Object key,
                            Object value)

      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 final Object setAttribute(Object key)

      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.

    - #### setAttributeIfAbsent

          public final Object setAttributeIfAbsent(Object key,
                                    Object value)

      Sets a user defined attribute if the attribute with the specified key is not set yet. This method is same with the following code except that the operation is performed atomically.

           if (containsAttribute(key)) {
               return getAttribute(key);
           } else {
               return setAttribute(key, value);
           }

      Specified by:
        `setAttributeIfAbsent` in interface `IoSession`

    - #### setAttributeIfAbsent

          public final Object setAttributeIfAbsent(Object key)

      Sets a user defined attribute without a value if the attribute with the specified key is not set yet. This is useful when you just want to put a 'mark' attribute. Its value is set to `Boolean.TRUE`. This method is same with the following code except that the operation is performed atomically.

           if (containsAttribute(key)) {
               return getAttribute(key);  // might not always be Boolean.TRUE.
           } else {
               return setAttribute(key);
           }

      Specified by:
        `setAttributeIfAbsent` in interface `IoSession`

    - #### removeAttribute

          public final Object removeAttribute(Object key)

      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.

    - #### removeAttribute

          public final boolean removeAttribute(Object key,
                                Object value)

      Removes a user defined attribute with the specified key if the current attribute value is equal to the specified value. This method is same with the following code except that the operation is performed atomically.

           if (containsAttribute(key) && getAttribute(key).equals(value)) {
               removeAttribute(key);
               return true;
           } else {
               return false;
           }

      Specified by:
        `removeAttribute` in interface `IoSession`

    - #### replaceAttribute

          public final boolean replaceAttribute(Object key,
                                 Object oldValue,
                                 Object newValue)

      Replaces a user defined attribute with the specified key if the value of the attribute is equals to the specified old value. This method is same with the following code except that the operation is performed atomically.

           if (containsAttribute(key) && getAttribute(key).equals(oldValue)) {
               setAttribute(key, newValue);
               return true;
           } else {
               return false;
           }

      Specified by:
        `replaceAttribute` in interface `IoSession`

    - #### containsAttribute

          public final boolean containsAttribute(Object key)

      Returns `true` if this session contains the attribute with the specified `key`.
      Specified by:
        `containsAttribute` in interface `IoSession`

    - #### getAttributeKeys

          public final Set<Object> getAttributeKeys()

      Returns the set of keys of all user-defined attributes.
      Specified by:
        `getAttributeKeys` in interface `IoSession`

    - #### getAttributeMap

          public final IoSessionAttributeMap getAttributeMap()

      TODO Add method documentation

    - #### setAttributeMap

          public final void setAttributeMap(IoSessionAttributeMap attributes)

      TODO Add method documentation

    - #### setWriteRequestQueue

          public final void setWriteRequestQueue(WriteRequestQueue writeRequestQueue)

      Create a new close aware write queue, based on the given write queue.
      Parameters:
        `writeRequestQueue` - The write request queue

    - #### suspendRead

          public final void suspendRead()

      Suspends read operations for this session.
      Specified by:
        `suspendRead` in interface `IoSession`

    - #### suspendWrite

          public final void suspendWrite()

      Suspends write operations for this session.
      Specified by:
        `suspendWrite` in interface `IoSession`

    - #### resumeRead

          public final void resumeRead()

      Resumes read operations for this session.
      Specified by:
        `resumeRead` in interface `IoSession`

    - #### resumeWrite

          public final void resumeWrite()

      Resumes write operations for this session.
      Specified by:
        `resumeWrite` in interface `IoSession`

    - #### isReadSuspended

          public boolean isReadSuspended()

      Is read operation is suspended for this session.
      Specified by:
        `isReadSuspended` in interface `IoSession`
      Returns:
        `true` if suspended

    - #### isWriteSuspended

          public boolean isWriteSuspended()

      Is write operation is suspended for this session.
      Specified by:
        `isWriteSuspended` in interface `IoSession`
      Returns:
        `true` if suspended

    - #### getReadBytes

          public final long getReadBytes()

      Returns the total number of bytes which were read from this session.
      Specified by:
        `getReadBytes` in interface `IoSession`

    - #### getWrittenBytes

          public final long getWrittenBytes()

      Returns the total number of bytes which were written to this session.
      Specified by:
        `getWrittenBytes` in interface `IoSession`

    - #### getReadMessages

          public final long getReadMessages()

      Returns the total number of messages which were read and decoded from this session.
      Specified by:
        `getReadMessages` in interface `IoSession`

    - #### getWrittenMessages

          public final long getWrittenMessages()

      Returns the total number of messages which were written and encoded by this session.
      Specified by:
        `getWrittenMessages` in interface `IoSession`

    - #### getReadBytesThroughput

          public final double getReadBytesThroughput()

      Returns the number of read bytes per second.
      Specified by:
        `getReadBytesThroughput` in interface `IoSession`

    - #### getWrittenBytesThroughput

          public final double getWrittenBytesThroughput()

      Returns the number of written bytes per second.
      Specified by:
        `getWrittenBytesThroughput` in interface `IoSession`

    - #### getReadMessagesThroughput

          public final double getReadMessagesThroughput()

      Returns the number of read messages per second.
      Specified by:
        `getReadMessagesThroughput` in interface `IoSession`

    - #### getWrittenMessagesThroughput

          public final double getWrittenMessagesThroughput()

      Returns the number of written messages per second.
      Specified by:
        `getWrittenMessagesThroughput` in interface `IoSession`

    - #### updateThroughput

          public final void updateThroughput(long currentTime,
                              boolean force)

      Update all statistical properties related with throughput assuming the specified time is the current time. By default this method returns silently without updating the throughput properties if they were calculated already within last `calculation interval`. If, however, `force` is specified as `true`, this method updates the throughput properties immediately.
      Specified by:
        `updateThroughput` in interface `IoSession`
      Parameters:
        `currentTime` - the current time in milliseconds

    - #### getScheduledWriteBytes

          public final long getScheduledWriteBytes()

      Returns the number of bytes which are scheduled to be written to this session.
      Specified by:
        `getScheduledWriteBytes` in interface `IoSession`

    - #### getScheduledWriteMessages

          public final int getScheduledWriteMessages()

      Returns the number of messages which are scheduled to be written to this session.
      Specified by:
        `getScheduledWriteMessages` in interface `IoSession`

    - #### setScheduledWriteBytes

          protected void setScheduledWriteBytes(int byteCount)

      TODO Add method documentation

    - #### setScheduledWriteMessages

          protected void setScheduledWriteMessages(int messages)

      TODO Add method documentation

    - #### increaseReadBytes

          public final void increaseReadBytes(long increment,
                               long currentTime)

      TODO Add method documentation

    - #### increaseReadMessages

          public final void increaseReadMessages(long currentTime)

      TODO Add method documentation

    - #### increaseWrittenBytes

          public final void increaseWrittenBytes(int increment,
                                  long currentTime)

      TODO Add method documentation

    - #### increaseWrittenMessages

          public final void increaseWrittenMessages(WriteRequest request,
                                     long currentTime)

      TODO Add method documentation

    - #### increaseScheduledWriteBytes

          public final void increaseScheduledWriteBytes(int increment)

      TODO Add method documentation

    - #### increaseScheduledWriteMessages

          public final void increaseScheduledWriteMessages()

      TODO Add method documentation

    - #### decreaseScheduledBytesAndMessages

          public final void decreaseScheduledBytesAndMessages(WriteRequest request)

      TODO Add method documentation

    - #### getWriteRequestQueue

          public final WriteRequestQueue getWriteRequestQueue()

      TODO Add method documentation
      Specified by:
        `getWriteRequestQueue` in interface `IoSession`

    - #### getCurrentWriteRequest

          public final WriteRequest getCurrentWriteRequest()

      Returns the `WriteRequest` which is being processed by `IoService`.
      Specified by:
        `getCurrentWriteRequest` in interface `IoSession`
      Returns:
        `null` if and if only no message is being written

    - #### getCurrentWriteMessage

          public final Object getCurrentWriteMessage()

      Returns the message which is being written by `IoService`.
      Specified by:
        `getCurrentWriteMessage` in interface `IoSession`
      Returns:
        `null` if and if only no message is being written

    - #### setCurrentWriteRequest

          public final void setCurrentWriteRequest(WriteRequest currentWriteRequest)

      TODO setWriteRequestQueue.
      Specified by:
        `setCurrentWriteRequest` in interface `IoSession`

    - #### increaseReadBufferSize

          public final void increaseReadBufferSize()

      TODO Add method documentation

    - #### decreaseReadBufferSize

          public final void decreaseReadBufferSize()

      TODO Add method documentation

    - #### getCreationTime

          public final long getCreationTime()

      Specified by:
        `getCreationTime` in interface `IoSession`
      Returns:
        the session's creation time in milliseconds

    - #### getLastIoTime

          public final long getLastIoTime()

      Returns the time in millis when I/O occurred lastly.
      Specified by:
        `getLastIoTime` in interface `IoSession`

    - #### getLastReadTime

          public final long getLastReadTime()

      Returns the time in millis when read operation occurred lastly.
      Specified by:
        `getLastReadTime` in interface `IoSession`

    - #### getLastWriteTime

          public final long getLastWriteTime()

      Returns the time in millis when write operation occurred lastly.
      Specified by:
        `getLastWriteTime` in interface `IoSession`

    - #### isIdle

          public final boolean isIdle(IdleStatus status)

      Returns `true` if this session is idle for the specified `IdleStatus`.
      Specified by:
        `isIdle` in interface `IoSession`

    - #### isBothIdle

          public final boolean isBothIdle()

      Returns `true` if this session is `IdleStatus.BOTH_IDLE`.
      Specified by:
        `isBothIdle` in interface `IoSession`
      See Also:
        `IoSession.isIdle(IdleStatus)`

    - #### isReaderIdle

          public final boolean isReaderIdle()

      Returns `true` if this session is `IdleStatus.READER_IDLE`.
      Specified by:
        `isReaderIdle` in interface `IoSession`
      See Also:
        `IoSession.isIdle(IdleStatus)`

    - #### isWriterIdle

          public final boolean isWriterIdle()

      Returns `true` if this session is `IdleStatus.WRITER_IDLE`.
      Specified by:
        `isWriterIdle` in interface `IoSession`
      See Also:
        `IoSession.isIdle(IdleStatus)`

    - #### getIdleCount

          public final int getIdleCount(IdleStatus status)

      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 final long getLastIdleTime(IdleStatus status)

      Returns the time in milliseconds when the last `sessionIdle` event is fired for the specified `IdleStatus`.
      Specified by:
        `getLastIdleTime` in interface `IoSession`

    - #### increaseIdleCount

          public final void increaseIdleCount(IdleStatus status,
                               long currentTime)

      TODO Add method documentation

    - #### getBothIdleCount

          public final int getBothIdleCount()

      Returns the number of the fired continuous `sessionIdle` events for `IdleStatus.BOTH_IDLE`.
      Specified by:
        `getBothIdleCount` in interface `IoSession`
      See Also:
        `IoSession.getIdleCount(IdleStatus)`

    - #### getLastBothIdleTime

          public final long getLastBothIdleTime()

      Returns the time in milliseconds when the last `sessionIdle` event is fired for `IdleStatus.BOTH_IDLE`.
      Specified by:
        `getLastBothIdleTime` in interface `IoSession`
      See Also:
        `IoSession.getLastIdleTime(IdleStatus)`

    - #### getLastReaderIdleTime

          public final long getLastReaderIdleTime()

      Returns the time in milliseconds when the last `sessionIdle` event is fired for `IdleStatus.READER_IDLE`.
      Specified by:
        `getLastReaderIdleTime` in interface `IoSession`
      See Also:
        `IoSession.getLastIdleTime(IdleStatus)`

    - #### getLastWriterIdleTime

          public final long getLastWriterIdleTime()

      Returns the time in milliseconds when the last `sessionIdle` event is fired for `IdleStatus.WRITER_IDLE`.
      Specified by:
        `getLastWriterIdleTime` in interface `IoSession`
      See Also:
        `IoSession.getLastIdleTime(IdleStatus)`

    - #### getReaderIdleCount

          public final int getReaderIdleCount()

      Returns the number of the fired continuous `sessionIdle` events for `IdleStatus.READER_IDLE`.
      Specified by:
        `getReaderIdleCount` in interface `IoSession`
      See Also:
        `IoSession.getIdleCount(IdleStatus)`

    - #### getWriterIdleCount

          public final int getWriterIdleCount()

      Returns the number of the fired continuous `sessionIdle` events for `IdleStatus.WRITER_IDLE`.
      Specified by:
        `getWriterIdleCount` in interface `IoSession`
      See Also:
        `IoSession.getIdleCount(IdleStatus)`

    - #### getServiceAddress

          public SocketAddress getServiceAddress()

      Returns the socket address of the `IoService` listens to to manage this session. If this session is managed by `IoAcceptor`, it returns the `SocketAddress` which is specified as a parameter of `IoAcceptor.bind()`. If this session is managed by `IoConnector`, this method returns the same address with that of `IoSession.getRemoteAddress()`.
      Specified by:
        `getServiceAddress` in interface `IoSession`

    - #### hashCode

          public final int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public final boolean equals(Object o)

      TODO This is a ridiculous implementation. Need to be replaced.
      Overrides:
        `equals` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getService

          public IoService getService()

      Specified by:
        `getService` in interface `IoSession`
      Returns:
        the `IoService` which provides I/O service to this session.

    - #### notifyIdleness

          public static void notifyIdleness(Iterator<? extends IoSession> sessions,
                            long currentTime)

      Fires a `IoEventType.SESSION_IDLE` event to any applicable sessions in the specified collection.
      Parameters:
        `currentTime` - the current time (i.e. `System.currentTimeMillis()`)

    - #### notifyIdleSession

          public static void notifyIdleSession(IoSession session,
                               long currentTime)

      Fires a `IoEventType.SESSION_IDLE` event if applicable for the specified `session`.
      Parameters:
        `currentTime` - the current time (i.e. `System.currentTimeMillis()`)

Copyright © 2004-2012 Apache MINA Project. All Rights Reserved.