Basic Concepts : Real-Time Messaging
Estimated reading time: 3 minutesWhat is a Message
A message is the unit of data that is sent between two users OR multiple users in case of a group message.
A message in mesibo is a raw binary data, essentially an array of bytes. This allows you to send any arbitrary data in real-time, for example, a text message, a binary message, a WebRTC SDP, a TLV message, a JSON message, or anything limited only by your imagination.
Message Properties
Each message you send or receive has some properties. The following are some of the key properties on each message transmitted on mesibo.
Property | Description |
---|---|
destination | Can be a user(Also referred to as peer) OR a group of users(In which case, it is a groupid) |
expiry | Represents the time within which a message has to be delivered. Ranges from immediate (zero, for real-time-messages) to a few days and can be independently specified per-message basis at the time of sending. Mesibo will not deliver messages past its expiry. |
type | User defined type(Default 0). You can send different types of messages and apply different processing. For example, type 0 for normal messages and type 1 for JSON messages, etc. |
priority | Value can range between 0 and 15. 0 represents the highest priority and 15 represents the lowest. Mesibo will attempt to deliver higher priority messages before lower priority ones. |
identifier | A unique 64-bit identifier. You can assign your own identifier or it can be generated by the system. |
timestamp | Time of the message. Mesibo automatically adds a timestamp to each message when it was received by the mesibo server. |
status | Incoming messages can have the status “New” or “Read”. Similarly, outgoing messages are assigned a status “OUTBOX” when sending them. It then cycles through “Sent”, “Delivered”, “Read” or one of the error conditions like invalid destination expired, etc. |
Key characteristics of Messaging
Before we move forward to our next section on group messaging, let’s spend a minute to understand a few most important characteristics of messaging to make your apps reliable and consistent.
Delivery guarantee
A key feature of mesibo, and in fact any carrier-grade messaging systems, is reliable messaging. With reliable messaging, Mesibo guarantees that the message will be delivered once and only once to each destination, even in the event of system failure. This is crucial for many businesses as you don’t want your messages to be sent more than once or for your messages to be lost. You can set the expiry to control this.
In some cases, you may not care about the delivery guarantee (fire-and-forget) and you may configure so(by setting expiry to 0, and identifier to 0 to forget). Mesibo allows you to configure delivery guarantees as you require on a per-message basis through a message flag. Once a message is delivered or read, the message status will be updated.
Duplicate Detection
This is another important characteristic of any carrier-grade messaging systems like mesibo. Even if messages are retried, no messages should be delivered in duplicate. The server and client should ensure that any duplicate messages are removed from the queue, at the same time ensure that the delivery of the original message is ensured. Since, each message will have a unique identifier, there will be no-duplicates even with a resend.
Store and Forward
Any messages which can be delivered in real-time should be stored and should be delivered as soon as the destination is ready to receive it.
In the next section, we will get familiar with the API flow that is used by every mesibo application.
chat, message, destination, group messaging