Class Message

java.lang.Object
io.ably.lib.types.BaseMessage
io.ably.lib.types.Message
All Implemented Interfaces:
java.lang.Cloneable

public class Message
extends BaseMessage
Contains an individual message that is sent to, or received from, Ably.
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  Message.Batch
    static class  Message.Serializer  
  • Field Summary

    Fields 
    Modifier and Type Field Description
    java.lang.String connectionKey
    Key needed only in case one client is publishing this message on behalf of another client.
    MessageExtras extras
    A MessageExtras object of arbitrary key-value pairs that may contain metadata, and/or ancillary payloads.
    java.lang.String name
    The event name.

    Fields inherited from class io.ably.lib.types.BaseMessage

    clientId, connectionId, data, encoding, id, timestamp
  • Constructor Summary

    Constructors 
    Constructor Description
    Message()
    Default constructor
    Message​(java.lang.String name, java.lang.Object data)
    Construct a Message object with an event name and payload.
    Message​(java.lang.String name, java.lang.Object data, MessageExtras extras)
    Construct a Message object with an event name, payload, and a extras.
    Message​(java.lang.String name, java.lang.Object data, java.lang.String clientId)
    Construct a Message object with an event name, payload, and a unique client ID.
    Message​(java.lang.String name, java.lang.Object data, java.lang.String clientId, MessageExtras extras)
    Construct a Message object with an event name, payload, extras, and a unique client ID.
  • Method Summary

    Modifier and Type Method Description
    static Message fromEncoded​(com.google.gson.JsonObject messageJson, ChannelOptions channelOptions)
    A static factory method to create a Message object from a deserialized Message-like object encoded using Ably's wire protocol.
    static Message fromEncoded​(java.lang.String messageJson, ChannelOptions channelOptions)
    A static factory method to create a Message object from a deserialized Message-like object encoded using Ably's wire protocol.
    static Message[] fromEncodedArray​(com.google.gson.JsonArray messageArray, ChannelOptions channelOptions)
    A static factory method to create an array of Message objects from an array of deserialized Message-like object encoded using Ably's wire protocol.
    static Message[] fromEncodedArray​(java.lang.String messagesArray, ChannelOptions channelOptions)
    A static factory method to create an array of Message objects from an array of deserialized Message-like object encoded using Ably's wire protocol.
    protected void read​(com.google.gson.JsonObject map)
    Populate fields from JSON.
    java.lang.String toString()
    Generate a String summary of this Message

    Methods inherited from class io.ably.lib.types.BaseMessage

    countFields, decode, decode, encode, getDetails, readLong, readString, toJsonObject

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • name

      public java.lang.String name
      The event name.

      Spec: TM2g

    • extras

      public MessageExtras extras
      A MessageExtras object of arbitrary key-value pairs that may contain metadata, and/or ancillary payloads. Valid payloads include DeltaExtras, JsonObject.

      Spec: TM2i

    • connectionKey

      public java.lang.String connectionKey
      Key needed only in case one client is publishing this message on behalf of another client. The connectionKey will never be populated for messages received.

      Spec: TM2h

  • Constructor Details

    • Message

      public Message()
      Default constructor
    • Message

      public Message​(java.lang.String name, java.lang.Object data)
      Construct a Message object with an event name and payload.

      Spec: TM2

      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 object with an event name, payload, and a unique client ID.

      Spec: TM2

      Parameters:
      name - The event name.
      data - The message payload.
      clientId - The client ID of the publisher of this message.
    • Message

      public Message​(java.lang.String name, java.lang.Object data, MessageExtras extras)
      Construct a Message object with an event name, payload, and a extras.

      Spec: TM2

      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 object with an event name, payload, extras, and a unique client ID.

      Spec: TM2

      Parameters:
      name - The event name.
      data - The message payload.
      clientId - The client ID of the publisher of this message.
      extras - Extra information to be sent with this message.
  • Method Details

    • 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
      A static factory method to create a Message object from a deserialized Message-like object encoded using Ably's wire protocol.

      Spec: TM3

      Parameters:
      messageJson - A Message-like deserialized object.
      channelOptions - A ChannelOptions object. If you have an encrypted channel, use this to allow the library to decrypt the data.
      Returns:
      A Message object.
      Throws:
      MessageDecodeException
    • fromEncoded

      public static Message fromEncoded​(java.lang.String messageJson, ChannelOptions channelOptions) throws MessageDecodeException
      A static factory method to create a Message object from a deserialized Message-like object encoded using Ably's wire protocol.

      Spec: TM3

      Parameters:
      messageJson - A Message-like deserialized object.
      channelOptions - A ChannelOptions object. If you have an encrypted channel, use this to allow the library to decrypt the data.
      Returns:
      A Message object.
      Throws:
      MessageDecodeException
    • fromEncodedArray

      public static Message[] fromEncodedArray​(com.google.gson.JsonArray messageArray, ChannelOptions channelOptions) throws MessageDecodeException
      A static factory method to create an array of Message objects from an array of deserialized Message-like object encoded using Ably's wire protocol.

      Spec: TM3

      Parameters:
      messageArray - An array of Message-like deserialized objects.
      channelOptions - A ChannelOptions object. If you have an encrypted channel, use this to allow the library to decrypt the data.
      Returns:
      An array of Message objects.
      Throws:
      MessageDecodeException
    • fromEncodedArray

      public static Message[] fromEncodedArray​(java.lang.String messagesArray, ChannelOptions channelOptions) throws MessageDecodeException
      A static factory method to create an array of Message objects from an array of deserialized Message-like object encoded using Ably's wire protocol.

      Spec: TM3

      Parameters:
      messagesArray - An array of Message-like deserialized objects.
      channelOptions - A ChannelOptions object. If you have an encrypted channel, use this to allow the library to decrypt the data.
      Returns:
      An array of Message objects.
      Throws:
      MessageDecodeException
    • read

      protected void read​(com.google.gson.JsonObject map) throws MessageDecodeException
      Description copied from class: BaseMessage
      Populate fields from JSON.
      Overrides:
      read in class BaseMessage
      Throws:
      MessageDecodeException