Class MessageSerializer

java.lang.Object
com.tccc.kos.commons.web.websocket.router.msg.MessageSerializer

public class MessageSerializer extends Object
Convert a Message to text.
Version:
2022-07-12
  • Constructor Details

    • MessageSerializer

      public MessageSerializer()
  • Method Details

    • toInbound

      public InboundMessage toInbound(OutboundMessage msg)
      Convert an outbound message to an inbound message that can be routed.
      Parameters:
      msg - the message to convert
    • toString

      public String toString(RoutedMessage msg)
      Convert a Message to a string representation suitable for sending over websocket.
      Parameters:
      msg - the message to convert
    • toRaw

      public void toRaw(InboundMessage msg)
      Convert a Message back to raw representation. This is similar to toString(), except that instead of returning the serialized message it's stored back in the rawMsg property of the message so that toString() will simply return the raw data. This is useful if a message may be passed to toString() multiple times as once in raw form it just returns the raw string. If the message is already in raw form, this does nothing.