Chat system
Contents
- Chat system
- Syria
- Types of Chats
- Several existing open source solutions
- The drawbacks of JABBER/XMPP
- The lightweight Mqtt
- Architecture Design Implementation
Syria
For connected multi-user online games, chat is not limited.
Types of Chats
The categories here are categorized by the number of users.
Single Point type
As simple as Skype (QQ), you can chat with friends, one-on-one online.
Multi-point type
such as Skype, you can organize group chat freely.
Several existing open source solutions Ejabberd
Ejabberd (Instant Messaging server based on JABBER/XMPP protocol) is gameloft now very waste wood chat system. From an open source perspective, Ejabberd seems to be a good alternative to chatting.
Advantages
- Cross-platform, fault-tolerant, clustered and modular.
- Easy to expand (easy 50-line user authentication plugin code is integrated into the existing platform).
- Distributed, fault-tolerant, and based on open standards for real-time communication systems.
- A feature-rich XMPP server.
- They are also suitable for small-scale deployment and ultra-large-scale deployment, regardless of whether they need scalability.
Disadvantages
- For mobile internet, JABBER/XMPP is very bloated. (Before the company's distributed chat platform, when the group chat to 50 people, it is very laborious)
- Deployment trouble.
- Maintenance is poor, maintenance is very difficult.
OpenFire
OpenFire is developed in Java, and the open source real-time collaboration (RTC) server is based on the XMPP (Jabber) protocol. The advantage is easy-to-use installation, and also provides Web management tools.
The drawbacks of JABBER/XMPP
For mobile internet environment, XMPP is bloated, in practice, performance is not satisfactory, delay, group chat user support is not many. From the client side, more power consumption, message processing delay, the concurrency is not small.
The lightweight Mqtt
MQTT (Message Queuing Telemetry Transport) is an Instant Messaging protocol developed by IBM.
Advantages
- Friendly to the mobile side, save power, request volume per second more objective.
- The protocol is lightweight and the content agreement of the communication is freely organized.
Disadvantages
- The existing open source implementations are few and take some time to implement.
Architecture design implements HTTP protocol join Grouppost Group/<group-name>/join
Group-name: |
This is the group name that needs to be added to the chat |
Username |
User name |
Token |
User Tokens |
If the user joins successfully, the HTTP status 200 and the contents will be returned:
{ "chat_host": 1234 "port": "", "name": "", "id":, "users": { "" }}
To connect the domain name and port of the chat room
If join failed returns 500 status code and content:
The full
CHAT MESSAGE protocal
The command protocol that the client sends to the server is relatively straightforward and uses line directives. Spaces are separated and the first word is an instruction.
GET Group datetime
Group |
is a subscription group message |
Datetime: |
Is the time that the user last fetched the message, and if the limit over the service is exceeded, the last five minutes of the message is returned. |
Get a reply:
ok:1034\r\n[{' msg ': ' Hello group ' from ': ' user_id ', datetime: ' 2014-08-11 12:12:123 ', ...},{' msg ': ' Hello group ' from ' : ' User_id3 ', datetime: ' 2014-08-11 12:12:123 ', ...},...]
Protocol header behavior State and content length, separated by colons.
If it fails, the error message text is returned:
Error:100\r\nunknow Error
The design of Chat service is random