The design of Chat service is random

Source: Internet
Author: User

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
  1. Cross-platform, fault-tolerant, clustered and modular.
  2. Easy to expand (easy 50-line user authentication plugin code is integrated into the existing platform).
  3. Distributed, fault-tolerant, and based on open standards for real-time communication systems.
  4. A feature-rich XMPP server.
  5. They are also suitable for small-scale deployment and ultra-large-scale deployment, regardless of whether they need scalability.
Disadvantages
  1. 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)
  2. Deployment trouble.
  3. 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
  1. Friendly to the mobile side, save power, request volume per second more objective.
  2. The protocol is lightweight and the content agreement of the communication is freely organized.
Disadvantages
  1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.