Package io.ably.lib.types
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
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 classMessage.BatchA specification for a collection of messages to be sent using the batch APIstatic classMessage.Serializer
-
Field Summary
Fields Modifier and Type Field Description java.lang.StringconnectionKeyKey needed only in case one client is publishing this message on behalf of another client.MessageExtrasextrasExtras, if available.java.lang.StringnameThe event name, if available.-
Fields inherited from class io.ably.lib.types.BaseMessage
clientId, connectionId, data, encoding, id, timestamp
-
-
Constructor Summary
Constructors Constructor Description Message()Default constructorMessage(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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MessagefromEncoded(com.google.gson.JsonObject messageJson, ChannelOptions channelOptions)Refer Spec TM3
An alternative constructor that take an Message-JSON object and a channelOptions (optional), and return a Messagestatic MessagefromEncoded(java.lang.String messageJson, ChannelOptions channelOptions)Refer Spec TM3
An alternative constructor that takes a Stringified Message-JSON and a channelOptions (optional), and return a Messagestatic Message[]fromEncodedArray(com.google.gson.JsonArray messageArray, ChannelOptions channelOptions)Refer Spec TM3
An alternative constructor that takes a Messages JsonArray and a channelOptions (optional), and return array of Messages.static Message[]fromEncodedArray(java.lang.String messagesArray, ChannelOptions channelOptions)protected voidread(com.google.gson.JsonObject map)Populate fields from JSON.java.lang.StringtoString()Generate a String summary of this Message-
Methods inherited from class io.ably.lib.types.BaseMessage
countFields, decode, decode, encode, getDetails, readLong, readString, toJsonObject
-
-
-
-
Field Detail
-
name
public java.lang.String name
The event name, if available.
-
extras
public MessageExtras extras
Extras, 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 namedata- 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 namedata- the message payloadclientId- 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 namedata- the message payloadextras- 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 namedata- the message payloadclientId- the client identifierextras- extra information to be sent with this message
-
-
Method Detail
-
toString
public java.lang.String toString()
Generate a String summary of this Message- Overrides:
toStringin classjava.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
-
fromEncodedArray
public static Message[] fromEncodedArray(java.lang.String messagesArray, ChannelOptions channelOptions) throws MessageDecodeException
- Parameters:
messagesArray-channelOptions-- Returns:
- Throws:
MessageDecodeException
-
read
protected void read(com.google.gson.JsonObject map) throws MessageDecodeExceptionDescription copied from class:BaseMessagePopulate fields from JSON.- Overrides:
readin classBaseMessage- Throws:
MessageDecodeException
-
-