java.lang.Object
net.i2p.router.ClientMessage

public class ClientMessageextends Object
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 Details

    • _payload

      private final Payload _payload
      The I2CP message carried.
    • _destination

      private final Destination _destination
      The client this message is for.
    • _fromDestination

      private final Destination _fromDestination
      The client it came from, for received messages.
    • _senderConfig

      private final SessionConfig _senderConfig
      Config of the session that sent it.
    • _destinationHash

      private final Hash _destinationHash
      Hash of the destination.
    • _messageId

      private final MessageId _messageId
      Id for matching replies.
    • _messageNonce

      private final long _messageNonce
      Nonce for deduplication.
    • _expiration

      private final long _expiration
      Time past which the message is dropped.
    • _flags

      private final int _flags
      Flags 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 to
      payload - the message payload
      config - the session config of the sending client
      fromDest - the source destination
      msgID - the router's ID for this message
      messageNonce - the client's ID for this message
      expiration - the expiration time
      flags - the message flags
    • ClientMessage

      public ClientMessage(Hash toDestHash, Payload payload)
      For inbound (from remote dest).
      Parameters:
      toDestHash - the destination hash
      payload - the message payload
  • Method Details

    • getPayload

      public Payload getPayload()
      Retrieve the payload of the message. All ClientMessage objects should have a payload.
      Returns:
      the payload carried by this message, never null
    • getDestination

      public Destination getDestination()
      Retrieve the destination to which this message is directed. Valid for outbound; null for inbound. If null, use getDestinationHash().
      Returns:
      the resolved destination, or null if only the hash is known
    • getFromDestination

      public Destination getFromDestination()
      Valid for outbound; null for inbound.
      Returns:
      the from destination
    • getDestinationHash

      public Hash getDestinationHash()
      Retrieve the destination to which this message is directed. Valid for inbound; null for outbound. If null, use getDestination().
      Returns:
      the destination hash
    • getMessageId

      public MessageId getMessageId()
      Valid for outbound; null for inbound.
      Returns:
      the message ID
    • getMessageNonce

      public long getMessageNonce()
      Valid for outbound; 0 for inbound.
      Returns:
      the message nonce
    • getSenderConfig

      public SessionConfig 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