Package io.ably.lib.types
Class BaseMessage
java.lang.Object
io.ably.lib.types.BaseMessage
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
-
Message
,PresenceMessage
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe client ID of the publisher of this message.The connection ID of the publisher of this message.The message payload, if provided.This is typically empty, as all messages received from Ably are automatically decoded client-side using this value.A Unique ID assigned by Ably to this message.long
Timestamp of when the message was received by Ably, as milliseconds since the Unix epoch. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected int
void
decode
(ChannelOptions opts) void
decode
(ChannelOptions opts, DecodingContext context) void
encode
(ChannelOptions opts) void
getDetails
(StringBuilder builder) Generate a String summary of this BaseMessage.protected void
read
(com.google.gson.JsonObject map) Populate fields from JSON.protected Integer
Read an optional numerical value.protected Long
Read an optional numerical value.protected String
readString
(com.google.gson.JsonObject map, String key) Read an optional textual value.static com.google.gson.JsonObject
toJsonObject
(BaseMessage message) Base for gson serialisers.
-
Field Details
-
id
A 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
The client ID of the publisher of this message.Spec: RSL1g1, TM2b
-
connectionId
The connection ID of the publisher of this message.Spec: TM2c
-
encoding
This 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
The message payload, if provided.Spec: TM2d
-
-
Constructor Details
-
BaseMessage
public BaseMessage()
-
-
Method Details
-
getDetails
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
Read an optional textual value.- Returns:
- The value, or null if the key was not present in the map.
- Throws:
-
ClassCastException
- if an element exists for that key and that element is not aJsonPrimitive
or is not a valid string value.
-
readLong
Read an optional numerical value.- Returns:
- The value, or null if the key was not present in the map.
- Throws:
-
ClassCastException
- if an element exists for that key and that element is not aJsonPrimitive
or is not a valid long value.
-
readInt
Read an optional numerical value.- Returns:
- The value, or null if the key was not present in the map.
- Throws:
-
ClassCastException
- if an element exists for that key and that element is not aJsonPrimitive
or is not a valid int value.
-
countFields
protected int countFields()
-