Class IncomingMessage

java.lang.Object
net.carcdr.yhocuspocus.protocol.IncomingMessage

public class IncomingMessage extends Object
Represents an incoming message from a client.

Incoming messages are decoded from binary format using the protocol: [documentName: varString][messageType: varInt][...payload]

  • Constructor Details

    • IncomingMessage

      public IncomingMessage(String documentName, MessageType type, byte[] payload, byte[] rawData)
      Creates a new incoming message.
      Parameters:
      documentName - the document name
      type - the message type
      payload - the message payload
      rawData - the original raw message data
  • Method Details

    • getDocumentName

      public String getDocumentName()
      Gets the document name from the message.
      Returns:
      document name (never null)
    • getType

      public MessageType getType()
      Gets the message type.
      Returns:
      message type (never null)
    • getPayload

      public byte[] getPayload()
      Gets the message payload.
      Returns:
      payload bytes (never null, may be empty)
    • getRawData

      public byte[] getRawData()
      Gets the original raw message data.
      Returns:
      raw message bytes (never null)
    • getToken

      public String getToken()
      Gets the authentication token from AUTH messages.

      For AUTH messages, the payload contains the token as a varString.

      Returns:
      authentication token, or null if not an AUTH message
    • getStatelessPayload

      public String getStatelessPayload()
      Gets the stateless message payload as a string.

      For STATELESS/BROADCAST_STATELESS messages, decodes the payload.

      Returns:
      stateless payload, or null if not a stateless message
    • toString

      public String toString()
      Overrides:
      toString in class Object