Get Started: Real-Time Messaging

Estimated reading time: 4 minutes

Prerequisites

Anatomy of 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.

destination

Each message has a destination where a message is sent to. The destination can be a user OR a group of users. The messages are sent to a destination in the order they are received on the server. The destination user is also referred to as peer in this document when the direction of the message is unspecified.

expiry

expiry represents the time within which a message has to be delivered. Expiry ranges from immediate (zero) 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. You can also set the expiry to zero for the messages that need to be delivered in real-time and not later. All messages will be retained by Mesibo until delivered or until their expiry is reached.

type

Each message can be assigned a type, the default type is 0. This allows you to send different types of messages and apply different processing to it. For example, you can use type 0 for normal messages and type 1 for JSON messages which require extra processing to display.

priority

priority represents the priority of the message. 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

Each message has a unique 64-bit identifier. You can assign your own identifier or it can be generated by the system. You can also set the identifier to be zero for messages that are of type fire-and-forget.

timestamp

time of the message. Mesibo automatically adds a timestamp to each message when it was received by the mesibo server.

status

Every message has a 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.

In some cases, you may not care about the delivery guarantee (fire-and-forget) and you may configure so. Mesibo allows you to configure delivery guarantees as you require on a per-message basis.

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.

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.

Anatomy of a Mesibo App >>

chat, message, destination, group messaging