java.lang.Object
net.i2p.data.i2cp.SessionId
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 Summary
FieldsConstructor Summary
Method Summary
All MethodsModifier and TypeMethodDescriptionbooleanCompares this session ID with another object for equality.intNumeric identifier of the session.inthashCode()Hash code derived from the session ID value.voidreadBytes(InputStream in) Read the session ID from a stream.voidsetSessionId(int id) New session ID.toString()Returns a string representation of this session ID.voidwriteBytes(OutputStream out) Writes the session ID to a stream.
Field Details
_sessionId
private int _sessionIdThe 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 rangeIllegalStateException- if already set
readBytes
Read the session ID from a stream.- Parameters:
in- the stream positioned at the two byte big-endian session id- Throws:
IllegalStateException- if already setDataFormatException- if the two bytes read are not a usable valueIOException- if the stream ends before two bytes are available
writeBytes
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 setIOException- if the stream cannot be written
equals
hashCode
toString