Class Message

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class Message
    extends BaseMessage
    A class representing an individual message to be sent or received via the Ably Realtime service.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Message.Batch
      A specification for a collection of messages to be sent using the batch API
      static class  Message.Serializer  
    • Constructor Summary

      Constructors 
      Constructor Description
      Message()
      Default constructor
      Message​(java.lang.String name, java.lang.Object data)
      Construct a message from event name and data.
      Message​(java.lang.String name, java.lang.Object data, MessageExtras extras)
      Construct a message from name, data, and extras.
      Message​(java.lang.String name, java.lang.Object data, java.lang.String clientId)
      Construct a message from name, data, and client id.
      Message​(java.lang.String name, java.lang.Object data, java.lang.String clientId, MessageExtras extras)
      Construct a message from name, data, client id, and extras.
    • Field Detail

      • name

        public java.lang.String name
        The event name, if available.
      • connectionKey

        public java.lang.String connectionKey
        Key needed only in case one client is publishing this message on behalf of another client.
    • Constructor Detail

      • Message

        public Message()
        Default constructor
      • Message

        public Message​(java.lang.String name,
                       java.lang.Object data)
        Construct a message from event name and data.
        Parameters:
        name - the event name
        data - the message payload
      • Message

        public Message​(java.lang.String name,
                       java.lang.Object data,
                       java.lang.String clientId)
        Construct a message from name, data, and client id.
        Parameters:
        name - the event name
        data - the message payload
        clientId - the client identifier
      • Message

        public Message​(java.lang.String name,
                       java.lang.Object data,
                       MessageExtras extras)
        Construct a message from name, data, and extras.
        Parameters:
        name - the event name
        data - the message payload
        extras - extra information to be sent with this message
      • Message

        public Message​(java.lang.String name,
                       java.lang.Object data,
                       java.lang.String clientId,
                       MessageExtras extras)
        Construct a message from name, data, client id, and extras.
        Parameters:
        name - the event name
        data - the message payload
        clientId - the client identifier
        extras - extra information to be sent with this message
    • Method Detail

      • toString

        public java.lang.String toString()
        Generate a String summary of this Message
        Overrides:
        toString in class java.lang.Object
        Returns:
        string
      • fromEncoded

        public static Message fromEncoded​(com.google.gson.JsonObject messageJson,
                                          ChannelOptions channelOptions)
                                   throws MessageDecodeException
        Refer Spec TM3
        An alternative constructor that take an Message-JSON object and a channelOptions (optional), and return a Message
        Parameters:
        messageJson -
        channelOptions -
        Returns:
        Throws:
        MessageDecodeException
      • fromEncoded

        public static Message fromEncoded​(java.lang.String messageJson,
                                          ChannelOptions channelOptions)
                                   throws MessageDecodeException
        Refer Spec TM3
        An alternative constructor that takes a Stringified Message-JSON and a channelOptions (optional), and return a Message
        Parameters:
        messageJson -
        channelOptions -
        Returns:
        Throws:
        MessageDecodeException
      • fromEncodedArray

        public static Message[] fromEncodedArray​(com.google.gson.JsonArray messageArray,
                                                 ChannelOptions channelOptions)
                                          throws MessageDecodeException
        Refer Spec TM3
        An alternative constructor that takes a Messages JsonArray and a channelOptions (optional), and return array of Messages.
        Parameters:
        messageArray -
        channelOptions -
        Returns:
        Throws:
        MessageDecodeException