Package io.ably.lib.types
Class Message
java.lang.Object
io.ably.lib.types.BaseMessage
io.ably.lib.types.Message
- All Implemented Interfaces:
Cloneable
Contains an individual message that is sent to, or received from, Ably.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Sets the channel names and message contents toAblyBase.publishBatch(io.ably.lib.types.Message.Batch[], io.ably.lib.types.ChannelOptions)
.static class
static class
-
Field Summary
FieldsModifier and TypeFieldDescription(TM2j) action enumKey needed only in case one client is publishing this message on behalf of another client.(TM2o) createdAt time in milliseconds since epoch.A MessageExtras object of arbitrary key-value pairs that may contain metadata, and/or ancillary payloads.The event name.(TM2n) operation object – data object that may contain the `optional` attributes.(TM2l) ref string – an opaque string that uniquely identifies some referenced message.(TM2m) refType string – an opaque string that identifies the type of this reference.(TM2k) serial string – an opaque string that uniquely identifies the message.(TM2p) version string – an opaque string that uniquely identifies the message, and is different for different versions.Fields inherited from class io.ably.lib.types.BaseMessage
clientId, connectionId, data, encoding, id, timestamp
-
Constructor Summary
ConstructorsConstructorDescriptionMessage()
Default constructorConstruct a Message object with an event name and payload.Message
(String name, Object data, MessageExtras extras) Construct a Message object with an event name, payload, and a extras.Construct a Message object with an event name, payload, and a unique client ID.Message
(String name, Object data, String clientId, MessageExtras extras) Construct a Message object with an event name, payload, extras, and a unique client ID. -
Method Summary
Modifier and TypeMethodDescriptionstatic 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
(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
(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.toString()
Generate a String summary of this MessageMethods inherited from class io.ably.lib.types.BaseMessage
countFields, decode, decode, encode, getDetails, readInt, readLong, readString, toJsonObject
-
Field Details
-
name
The event name.Spec: TM2g
-
extras
A MessageExtras object of arbitrary key-value pairs that may contain metadata, and/or ancillary payloads. Valid payloads includeDeltaExtras
,JsonObject
.Spec: TM2i
-
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
-
serial
(TM2k) serial string – an opaque string that uniquely identifies the message. If a message received from Ably (whether over realtime or REST, eg history) with an action of MESSAGE_CREATE does not contain a serial, the SDK must set it equal to its version. -
version
(TM2p) version string – an opaque string that uniquely identifies the message, and is different for different versions. (May not be populated depending on app & channel namespace settings) -
action
(TM2j) action enum -
createdAt
(TM2o) createdAt time in milliseconds since epoch. If a message received from Ably (whether over realtime or REST, eg history) with an action of MESSAGE_CREATE does not contain a createdAt, the SDK must set it equal to the TM2f timestamp. -
refSerial
(TM2l) ref string – an opaque string that uniquely identifies some referenced message. -
refType
(TM2m) refType string – an opaque string that identifies the type of this reference. -
operation
(TM2n) operation object – data object that may contain the `optional` attributes.
-
-
Constructor Details
-
Message
public Message()Default constructor -
Message
Construct a Message object with an event name and payload.Spec: TM2
- Parameters:
-
name
- The event name. -
data
- The message payload.
-
Message
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
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
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
Generate a String summary of this Message -
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
- AChannelOptions
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(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
- AChannelOptions
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
- AChannelOptions
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(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
- AChannelOptions
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
Description copied from class:BaseMessage
Populate fields from JSON.- Overrides:
-
read
in classBaseMessage
- Throws:
MessageDecodeException
-