Interface IoSession

    • Method Detail

      • getId

        long getId()
        Returns:
        a unique identifier for this session. Every session has its own ID which is different from any other.
      • getAcceptanceAddress

        SocketAddress getAcceptanceAddress()
        Returns:
        The service address through which this session was accepted - null if session was initiated by this peer instead of being accepted
      • getAttribute

        Object getAttribute​(Object key)
        Returns the value of the user-defined attribute of this session.
        Parameters:
        key - the key of the attribute
        Returns:
        null if there is no attribute with the specified key
      • setAttribute

        Object setAttribute​(Object key,
                            Object value)
        Sets a user-defined attribute.
        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.
      • setAttributeIfAbsent

        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);
         }
         
        Parameters:
        key - The key of the attribute we want to set
        value - The value we want to set
        Returns:
        The old value of the attribute - null if not found.
      • removeAttribute

        Object removeAttribute​(Object key)
        Removes a user-defined attribute with the specified key.
        Parameters:
        key - The key of the attribute we want to remove
        Returns:
        The old value of the attribute - null if not found.
      • shudownOutputStream

        void shudownOutputStream()
                          throws IOException
        Handle received EOF.
        Throws:
        IOException - If failed to shutdown the stream