|
| 1 | +--- |
| 2 | +title: Messages |
| 3 | +meta_description: "Realtime Client Library SDK API reference section for the message object." |
| 4 | +meta_keywords: "Ably, Ably realtime, API Reference, Realtime SDK, message, messages" |
| 5 | +redirect_from: |
| 6 | + - /docs/api/versions/v1.1/realtime-sdk/messages |
| 7 | + - /docs/api/versions/v1.0/realtime-sdk/messages |
| 8 | + - /docs/api/versions/v0.8/realtime-sdk/messages |
| 9 | +--- |
| 10 | + |
| 11 | +## <If lang="javascript,nodejs,flutter,csharp,objc,swift">Properties</If><If lang="ruby">Attributes</If><If lang="java">Members</If> <a id="#properties" /> |
| 12 | + |
| 13 | +A `Message` represents an individual message that is sent to or received from Ably. |
| 14 | + |
| 15 | +### <If lang="javascript,nodejs,flutter,objc,swift,ruby,java">name</If><If lang="csharp">Name</If> <a id="#name" /> |
| 16 | + |
| 17 | +The event name, if provided. <br />_Type: `String`_ |
| 18 | + |
| 19 | +### <If lang="javascript,nodejs,flutter,objc,swift,ruby,java">data</If><If lang="csharp">Data</If> <a id="#data" /> |
| 20 | + |
| 21 | +The message payload, if provided.<br />_Type: <If lang="javascript,nodejs">`String`, `StringBuffer`, `JSON Object`</If><If lang="java">`String`, `ByteArray`, `JSONObject`, `JSONArray`</If><If lang="csharp">`String`, `byte[]`, `plain C# object that can be serialized to JSON`</If><If lang="ruby">`String`, `Binary` (ASCII-8BIT String), `Hash`, `Array`</If><If lang="objc">`NSString *`, `NSData *`, `NSDictionary *`, `NSArray *`</If><If lang="swift">`String`, `NSData`, `Dictionary`, `Array`</If><If lang="flutter">`String`, `Map`, `List`</If>_ |
| 22 | + |
| 23 | +### <If lang="javascript,nodejs,flutter,objc,swift,ruby,java">extras</If><If lang="csharp">Extras</If> <a id="#extras" /> |
| 24 | + |
| 25 | +Metadata and/or ancillary payloads, if provided. Valid payloads include [`push`](/docs/push/publish#payload), [`headers`](/docs/channels#metadata) (a map of strings to strings for arbitrary customer-supplied metadata), [`ephemeral`](/docs/pub-sub/advanced#ephemeral), and [`privileged`](/docs/platform/integrations/webhooks#skipping).<br />_Type: <If lang="java">`JSONObject`, `JSONArray`</If><If lang="csharp">plain C# object that can be converted to JSON</If><If lang="javascript,nodejs">`JSON Object`</If><If lang="ruby">`Hash`, `Array`</If><If lang="swift">`Dictionary`, `Array`</If><If lang="objc">`NSDictionary *`, `NSArray *`</If>_ |
| 26 | + |
| 27 | +### <If lang="javascript,nodejs,flutter,objc,swift,ruby,java">id</If><If lang="csharp">Id</If> <a id="#id" /> |
| 28 | + |
| 29 | +A Unique ID assigned by Ably to this message.<br />_Type: `String`_ |
| 30 | + |
| 31 | +### <If lang="javascript,nodejs,flutter,objc,swift,java">clientId</If><If lang="csharp">ClientId</If><If lang="ruby,python">client_id</If> <a id="#client-id" /> |
| 32 | + |
| 33 | +The client ID of the publisher of this message.<br />_Type: `String`_ |
| 34 | + |
| 35 | +### <If lang="javascript,nodejs,flutter,objc,swift,java">connectionId</If><If lang="csharp">ConnectionId</If><If lang="ruby,python">connection_id</If> <a id="#connection-id" /> |
| 36 | + |
| 37 | +The connection ID of the publisher of this message.<br />_Type: `String`_ |
| 38 | + |
| 39 | +### <If lang="javascript,nodejs,flutter,objc,swift,java">connectionKey</If><If lang="csharp,go">ConnectionKey</If><If lang="ruby,python">connection_key</If> <a id="#connection-key" /> |
| 40 | + |
| 41 | +A connection key, which can optionally be included for a REST publish as part of the [publishing on behalf of a realtime client functionality](/docs/pub-sub/advanced#publish-on-behalf).<br />_Type: `String`_ |
| 42 | + |
| 43 | +### <If lang="javascript,nodejs,flutter,objc,swift,ruby,java">timestamp</If><If lang="csharp">Timestamp</If> <a id="#timestamp" /> |
| 44 | + |
| 45 | +Timestamp when the message was first received by the Ably, as <If lang="javascript,nodejs,flutter,swift,csharp,objc,java">milliseconds since the epoch</If><If lang="ruby">a `Time` object</If>.<br />_Type: <If lang="javascript,nodejs,flutter">`Integer`</If><If lang="java">`Long Integer`</If><If lang="csharp">`DateTimeOffset`</If><If lang="ruby">`Time`</If><If lang="objc,swift">`NSDate`</If>_ |
| 46 | + |
| 47 | +### <If lang="javascript,nodejs,flutter,objc,swift,ruby,java">encoding</If><If lang="csharp">Encoding</If> <a id="#encoding" /> |
| 48 | + |
| 49 | +This will typically be 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 will contain the remaining transformations not applied to the `data` payload.<br />_Type: `String`_ |
| 50 | + |
| 51 | +<If lang="javascript,nodejs"> |
| 52 | + |
| 53 | +### <If lang="javascript,nodejs,flutter,objc,swift,ruby,java">action</If> <a id="#action" /> |
| 54 | + |
| 55 | +The action type of the message, one of the [`MessageAction`](/docs/api/realtime-sdk/types#message-action) enum values.<br />_Type: `int enum { MESSAGE_CREATE, MESSAGE_UPDATE, MESSAGE_DELETE, META, MESSAGE_SUMMARY }`_ |
| 56 | + |
| 57 | +### <If lang="javascript,nodejs,flutter,objc,swift,ruby,java">serial</If> <a id="#serial" /> |
| 58 | + |
| 59 | +A server-assigned identifier that will be the same in all future updates of this message. It can be used to add annotations to a message. Serial will only be set if you enable annotations in [channel rules](/docs/channels#rules).<br />_Type: `String`_ |
| 60 | + |
| 61 | +### <If lang="javascript,nodejs,flutter,objc,swift,ruby,java">annotations</If> <a id="#annotations" /> |
| 62 | + |
| 63 | +An object containing information about annotations that have been made to the object.<br />_Type: [`MessageAnnotations`](/docs/api/realtime-sdk/types#message-annotations)_ |
| 64 | + |
| 65 | +</If> |
| 66 | + |
| 67 | +### Message constructors <a id="constructors" /> |
| 68 | + |
| 69 | +#### <If lang="javascript,nodejs,flutter,csharp,objc,swift,ruby,java">Message.fromEncoded</If> <a id="#message-from-encoded" /> |
| 70 | + |
| 71 | +`Message.fromEncoded(Object encodedMsg, ChannelOptions channelOptions?) -> Message` |
| 72 | + |
| 73 | +A static factory method to create a [`Message`](/docs/api/realtime-sdk/types#message) from a deserialized `Message`-like object encoded using Ably's wire protocol. |
| 74 | + |
| 75 | +##### Parameters |
| 76 | + |
| 77 | +| Parameter | Description | Type | |
| 78 | +|-----------|-------------|------| |
| 79 | +| encodedMsg | A `Message`-like deserialized object. | `Object` | |
| 80 | +| channelOptions | An optional [`ChannelOptions`](/docs/api/realtime-sdk/types#channel-options). If you have an encrypted channel, use this to allow the library can decrypt the data. | `Object` | |
| 81 | + |
| 82 | +##### Returns |
| 83 | + |
| 84 | +A [`Message`](/docs/api/realtime-sdk/types#message) object |
| 85 | + |
| 86 | +#### <If lang="javascript,nodejs,flutter,objc,swift,ruby,java">Message.fromEncodedArray</If> <a id="#message-from-encoded-array" /> |
| 87 | + |
| 88 | +`Message.fromEncodedArray(Object[] encodedMsgs, ChannelOptions channelOptions?) -> Message[]` |
| 89 | + |
| 90 | +A static factory method to create an array of [`Messages`](/docs/api/realtime-sdk/types#message) from an array of deserialized `Message`-like object encoded using Ably's wire protocol. |
| 91 | + |
| 92 | +##### Parameters |
| 93 | + |
| 94 | +| Parameter | Description | Type | |
| 95 | +|-----------|-------------|------| |
| 96 | +| encodedMsgs | An array of `Message`-like deserialized objects. | `Array` | |
| 97 | +| channelOptions | An optional [`ChannelOptions`](/docs/api/realtime-sdk/types#channel-options). If you have an encrypted channel, use this to allow the library can decrypt the data. | `Object` | |
| 98 | + |
| 99 | +##### Returns |
| 100 | + |
| 101 | +An `Array` of [`Message`](/docs/api/realtime-sdk/types#message) objects |
| 102 | + |
| 103 | +## MessageAnnotations <a id="#message-annotations" /> |
| 104 | + |
| 105 | +#### <If lang="javascript,nodejs,flutter,objc,csharp,swift">Properties</If><If lang="java">Members</If><If lang="ruby">Attributes</If> |
| 106 | + |
| 107 | +| Property | Description | Type | |
| 108 | +|----------|-------------|------| |
| 109 | +| summary | An object whose keys are annotation types, and the values are aggregated summaries for that annotation type | `Record<String, JsonObject>` | |
0 commit comments