Messages
Threads allow the exchange of messages. In this section, let's take a closer look at the structure of messages and how to send them. We will also discuss some good practice when working with Threads.
About Messages
The structure of a message and a brief description of its elements is outlined in the following table:
| field | type | encrypted | description |
|---|---|---|---|
data | binary | yes | content of the message |
info | ServerInfo | no | additional information assigned by the server e.g. author, creationDate, messageID and threadID |
privateMeta | binary | yes | additional information about the message |
publicMeta | binary | no | additional public information about the message, also accessible through PrivMX Bridge API |
Define Structure
Thread's architecture does not require you to use a specific data structure inside the messages. So before working with Threads, define what what kind of messages you want to send.
We recommend future-proofing your messages right from the start, i.e. choosing an easily modifiable format.
It is also a good idea to include its type and version in the structure of the message.
Here is an example message structure that you can use in your project.
Remember that it is only an example and you should consider your app's requirements and limitations.
Sample code on this page is based on the initial assumptions.
Sending Messages
Sending a simple message to the given Thread:
Getting Messages
To get a list of messages inside a Thread, use getMessages method. Because data inside messages is in core::Buffer
you have to deserialize it to human-readable string.
PrivMX Endpoint library takes care of encrypting your data before sending it to PrivMX Bridge.
Reading the messages of the Thread (limited to the 100 newest entries as described by the defaultListQuery object):
Deleting a Message
To delete a message, you need to use the deleteMessage(...) method.
We use cookies on our website. We use them to ensure proper functioning of the site and, if you agree, for purposes such as analytics, marketing, and targeting ads.