Package io.ably.lib.types
Class BaseMessage
java.lang.Object
io.ably.lib.types.BaseMessage
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
Message,PresenceMessage
public class BaseMessage
extends java.lang.Object
implements java.lang.Cloneable
-
Field Summary
Fields Modifier and Type Field Description java.lang.StringclientIdThe client ID of the publisher of this message.java.lang.StringconnectionIdThe connection ID of the publisher of this message.java.lang.ObjectdataThe message payload, if provided.java.lang.StringencodingThis is typically empty, as all messages received from Ably are automatically decoded client-side using this value.java.lang.StringidA Unique ID assigned by Ably to this message.longtimestampTimestamp of when the message was received by Ably, as milliseconds since the Unix epoch. -
Constructor Summary
Constructors Constructor Description BaseMessage() -
Method Summary
Modifier and Type Method Description protected intcountFields()voiddecode(ChannelOptions opts)voiddecode(ChannelOptions opts, DecodingContext context)voidencode(ChannelOptions opts)voidgetDetails(java.lang.StringBuilder builder)Generate a String summary of this BaseMessage.protected voidread(com.google.gson.JsonObject map)Populate fields from JSON.protected java.lang.LongreadLong(com.google.gson.JsonObject map, java.lang.String key)Read an optional numerical value.protected java.lang.StringreadString(com.google.gson.JsonObject map, java.lang.String key)Read an optional textual value.static com.google.gson.JsonObjecttoJsonObject(BaseMessage message)Base for gson serialisers.
-
Field Details
-
id
public java.lang.String idA Unique ID assigned by Ably to this message.Spec: TM2a
-
timestamp
public long timestampTimestamp of when the message was received by Ably, as milliseconds since the Unix epoch.Spec: TM2f
-
clientId
public java.lang.String clientIdThe client ID of the publisher of this message.Spec: RSL1g1, TM2b
-
connectionId
public java.lang.String connectionIdThe connection ID of the publisher of this message.Spec: TM2c
-
encoding
public java.lang.String encodingThis is typically empty, as all messages received from Ably are automatically decoded client-side using this value. However, if the message encoding cannot be processed, this attribute contains the remaining transformations not applied to the data payload.Spec: TM2e
-
data
public java.lang.Object dataThe message payload, if provided.Spec: TM2d
-
-
Constructor Details
-
BaseMessage
public BaseMessage()
-
-
Method Details
-
getDetails
public void getDetails(java.lang.StringBuilder builder)Generate a String summary of this BaseMessage. -
decode
- Throws:
MessageDecodeException
-
decode
- Throws:
MessageDecodeException
-
encode
- Throws:
AblyException
-
toJsonObject
Base for gson serialisers. -
read
Populate fields from JSON.- Throws:
MessageDecodeException
-
readString
protected java.lang.String readString(com.google.gson.JsonObject map, java.lang.String key)Read an optional textual value.- Returns:
- The value, or null if the key was not present in the map.
- Throws:
java.lang.ClassCastException- if an element exists for that key and that element is not aJsonPrimitiveor is not a valid string value.
-
readLong
protected java.lang.Long readLong(com.google.gson.JsonObject map, java.lang.String key)Read an optional numerical value.- Returns:
- The value, or null if the key was not present in the map.
- Throws:
java.lang.ClassCastException- if an element exists for that key and that element is not aJsonPrimitiveor is not a valid long value.
-
countFields
protected int countFields()
-