java.lang.Object
net.i2p.router.ClientMessage
Wrap a message either destined for a local client or received from one. Note that an outbound message may get routed as an inbound message for local-local communication.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DestinationThe client this message is for.private final HashHash of the destination.private final longTime past which the message is dropped.private final intFlags only used for outbound messages.private final DestinationThe client it came from, for received messages.private final MessageIdId for matching replies.private final longNonce for deduplication.private final PayloadThe I2CP message carried.private final SessionConfigConfig of the session that sent it.Constructor Summary
ConstructorsConstructorDescriptionClientMessage(Destination toDest, Payload payload, SessionConfig config, Destination fromDest, MessageId msgID, long messageNonce, long expiration, int flags) For outbound (locally originated).ClientMessage(Hash toDestHash, Payload payload) For inbound (from remote dest).Method Summary
All MethodsModifier and TypeMethodDescriptionRetrieve the destination to which this message is directed.Retrieve the destination to which this message is directed.longExpiration requested by the client that sent the message.intgetFlags()Flags requested by the client that sent the message.Valid for outbound; null for inbound.Valid for outbound; null for inbound.longValid for outbound; 0 for inbound.Retrieve the payload of the message.Retrieve the session config of the client that sent the message.
Field Details
_payload
The I2CP message carried._destination
The client this message is for._fromDestination
The client it came from, for received messages._senderConfig
Config of the session that sent it._destinationHash
Hash of the destination._messageId
Id for matching replies._messageNonce
private final long _messageNonceNonce for deduplication._expiration
private final long _expirationTime past which the message is dropped._flags
private final int _flagsFlags only used for outbound messages.
Constructor Details
ClientMessage
public ClientMessage(Destination toDest, Payload payload, SessionConfig config, Destination fromDest, MessageId msgID, long messageNonce, long expiration, int flags) For outbound (locally originated).- Parameters:
toDest- the destination to send topayload- the message payloadconfig- the session config of the sending clientfromDest- the source destinationmsgID- the router's ID for this messagemessageNonce- the client's ID for this messageexpiration- the expiration timeflags- the message flags
ClientMessage
Method Details
getPayload
Retrieve the payload of the message. All ClientMessage objects should have a payload.- Returns:
- the payload carried by this message, never null
getDestination
Retrieve the destination to which this message is directed. Valid for outbound; null for inbound. If null, usegetDestinationHash().- Returns:
- the resolved destination, or null if only the hash is known
getFromDestination
Valid for outbound; null for inbound.- Returns:
- the from destination
getDestinationHash
Retrieve the destination to which this message is directed. Valid for inbound; null for outbound. If null, usegetDestination().- Returns:
- the destination hash
getMessageId
getMessageNonce
public long getMessageNonce()Valid for outbound; 0 for inbound.- Returns:
- the message nonce
getSenderConfig
Retrieve the session config of the client that sent the message. This will only be available if the client was local.- Returns:
- the session config
getExpiration
public long getExpiration()Expiration requested by the client that sent the message. This will only be available for locally originated messages.- Returns:
- expiry as milliseconds since the epoch, or 0 for none
getFlags
public int getFlags()Flags requested by the client that sent the message. This will only be available for locally originated messages.- Returns:
- the client's bitmask of delivery options, 0 if none set