java.lang.Object
net.i2p.data.i2cp.SessionId

public class SessionIdextends Object
Defines the token passed between the router and client to associate messages with a particular session. These IDs are not globally unique.

As of 0.9.48, does NOT extend DataStructureImpl.

  • Field Details

    • _sessionId

      private int _sessionId
      The session's 32-bit identifier.
  • Constructor Details

    • SessionId

      public SessionId()
      Creates a new SessionId with default value -1.
    • SessionId

      public SessionId(int id)
      0-65535.
      Parameters:
      id - 0-65535
  • Method Details

    • getSessionId

      public int getSessionId()
      Numeric identifier of the session.
      Returns:
      the session id, 0-65535
    • setSessionId

      public void setSessionId(int id)
      New session ID.
      Parameters:
      id - 0-65535
      Throws:
      IllegalArgumentException - if the ID is out of range
      IllegalStateException - if already set
    • readBytes

      public void readBytes(InputStream in) throws DataFormatException, IOException
      Read the session ID from a stream.
      Parameters:
      in - the stream positioned at the two byte big-endian session id
      Throws:
      IllegalStateException - if already set
      DataFormatException - if the two bytes read are not a usable value
      IOException - if the stream ends before two bytes are available
    • writeBytes

      public void writeBytes(OutputStream out) throws DataFormatException, IOException
      Writes the session ID to a stream.
      Parameters:
      out - the stream to write the two byte big-endian session id to
      Throws:
      DataFormatException - if the session id has not been set
      IOException - if the stream cannot be written
    • equals

      public boolean equals(Object obj)
      Compares this session ID with another object for equality.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Hash code derived from the session ID value.
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Returns a string representation of this session ID.
      Overrides:
      toString in class Object