Class ChatPayload

java.lang.Object
protocols.apps.chat.ChatPayload

public final class ChatPayload extends Object
The chat's own little "application protocol" that rides inside the broadcast's opaque byte[] payload. The broadcast layer doesn't know or care what these bytes mean — that's the whole point of layering: the broadcast moves bytes; the application decides what they are.

Two things travel by broadcast (i.e. to everyone):

Arrival and private messages go point-to-point instead — see ChatDirectMessage.

We hand-roll a tiny encoding with DataOutputStream (1 byte kind, then two length-prefixed UTF strings) so the wire format is obvious to a reader.

  • Constructor Details

  • Method Details

    • getKind

      public ChatPayload.Kind getKind()
    • getNick

      public String getNick()
    • getText

      public String getText()
    • encode

      public byte[] encode()
      Serialize to the bytes carried inside a broadcast message.
    • decode

      public static ChatPayload decode(byte[] bytes)
      Parse the bytes delivered by the broadcast layer back into a payload.