Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Light Extensible Messaging Protocol (LEMP) - A New and Simple Approach to Messaging

DZone's Guide to

Light Extensible Messaging Protocol (LEMP) - A New and Simple Approach to Messaging

Learn about the features and packet types of the Light Extensible Messaging Protocol (LEMP) for creating instant or IoT messaging platforms.

· Integration Zone
Free Resource

The Integration Zone is brought to you in partnership with Cloud Elements. What's below the surface of an API integration? Download The Definitive Guide to API Integrations to start building an API strategy.

When we think about building a new messaging platform (web, mobile, etc.), it is normal that using XMPP (Extensible Messaging and Presence Protocol) comes to our minds first. It is based on XML messages traveling through the network between the server and the client. Many popular applications use XMPP: WhatsApp, Nimbuzz, ChatMe, and more. But if you want to design a system which isn't complex and deals with JSON instead of XML, XMPP might be the heavyweight for you. You may really want to deal with JSON, not XML. You may also want to eliminate unnecessary protocol messages.

Light Extensible Messaging Protocol (LEMP), which is based on JSON, is born to be light and powerful with its extensibility. You can use it when you want to write a new instant messaging platform or make IoT devices to talk with each other.

Let's talk about some of the main features of LEMP and improve it together! The initial and incomplete project is on GitHub; take a look at LEMP on GitHub.

LEMP has three main packet types- do not forget that all details of these protocol packets are defined in the GitHub project. Let's briefly define these packets here:

1. Request

Every client-server architecture has a request-response relation. For example, when I run WhatsApp on my mobile phone, it communicates with the WhatsApp servers and makes an authentication request for me. Then, my mobile phone receives the authentication response and the application authenticates me. This kind of request messages can be thought of as questions. A client can ask a question to the server or the server can ask a question to a client. Then, the interlocutor answers the question; the answer is the response packet.

The main request types of LEMP are stated below, and every request has a response: success or error.

  • Authentication Request

  • User Followings (Roster) Requests

    • Register User's All Followings Request

    • Add New Following Request

    • Remove Following Request

    • Update Following Request

  • State (Last Offline) Request

  • Personnel Requests

    • Personal Information Request

    • Picture Set/Get Request

    • Personal Status Set/Get Request

  • Privacy Requests

    • Block Request

    • Unblock Request

  • Group Requests

    • Create Group Request

    • Add Users to Group Request

    • Banish Users From Group Request

    • Leave From Group Request

    • Terminate Group Request

    • Group Information Request

    • Add Admins Request

    • Get Admins Request

    • Picture Set/Get Request

    • Name Set/Get Request

    • Mute/Unmute Group Request

  •      Broadcast Group Requests

    • Create Broadcast Group Request

    • Add Users To Broadcast Group Request

    • Remove Users From Broadcast Group Request

    • Terminate Broadcast Group Request

    • Picture Set/Get Request

    • Name Set/Get Request

  • Server Requests

    • Server Time Request

    • Knock-Knock Request

2. Information

Information messages may be sent by the server to a client, or by a client to the server to inform a peer. For example, when you are going to send a message to a friend from WhatsApp and you open the chat window, you see his/her last offline date on the top of the chat window. If he/she opens the app while you are writing your message, you see that he/she came online on the top of the window. Namely, you are informed by the server that you friend has been online; this is an information message. Then, if he/she starts to write a message to you, you receive a "composing" information packet from him/her, and you see it on the chat window.

The main information packet types of LEMP are

  • Login/Logout information broadcast to followers 

  • Group Events information to members

    • Group created information

    • Member added to group information

    • Banished member from group information

    • Group terminated information       

    • Group picture changed information

    • Group name changed information    

3. Message

Messages are the packets for real communication. For example, you may send a text or video message to your friend from WhatsApp. These are client-to-client messages. They are sent to the server and then to their receivers. They build real communication.

The main message types of LEMP are

  • Text

  • Photo

  • Audio

  • Video

  • Location

The other messages are:

  • Server Receipt Message (which the server sends to the message sender for saying that it received the message).

  • Delivered Message (which the message receiver sends to the message sender for saying that it received the message).

  • Noticed Message (which the message receiver sends to the message sender for saying that it noticed/read the message).

All the messages are storable and should not be lost anywhere, such as the network.

As I said before, you can analyze all these types and read more details about the three packets on the LEMP GitHub page. By the way, this is not the final state of the protocol; it is going to evolve. You can be a contributor, too!

Your API is not enough. Learn why (and how) leading SaaS providers are turning their products into platforms with API integration in the ebook, Build Platforms, Not Products from Cloud Elements.

Topics:
xmpp ,protocol ,integration ,messaging

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}