Home  >  Q&A  >  body text

ajax - 如何自己实现一个聊天系统,覆盖(Web,Android,iOS)

一直对实时聊天这块内容迷糊。XMPP 好复杂的说。
对于一个超低配服务端,我想用 Go 压榨性能,利用好“协程”、队列的形式降低一点实时性(即收发消息有少许延迟)保证资源的低消耗,配合 Python 跑一些业务逻辑,调用一下 Push(极光)的推送保证离线消息的接收。
但是,还是搞不清楚应该如何去做,也不明白其中涉及哪些知识点。
另外,如何设计存储聊天信息的 Redis 数据库存储格式呢?
诸位,不吝赐教。

怪我咯怪我咯2765 days ago842

reply all(12)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 11:29:17

    Before, I was responsible for the implementation of the bottom layer of Android client chat for an Internet company. I had participated in the design of the chat protocol before, and I had a look at the server architecture. Since it went online, no user has reported missing messages, and the DAU is probably hundreds of thousands ( I forgot the exact number)

    Chat is really difficult to do. The key is not knowing what kind of chat system you want. For example, how high are the requirements for system reliability? As far as I know, xmpp does not guarantee reliability. So the first problem you encounter is the protocol. Different protocols have different features and characteristics.
    In comparison, the performance of the server is really not particularly important. After all, it is very laborious to implement the protocol correctly, and it also needs to leave room for subsequent development to facilitate expansion (this is still a matter of the protocol).
    As for the implementation of the client, it is not easy either, including database, long connection, and UI display. If something is not done well, a bunch of users will complain about the power consumption, data traffic, UI card and other small things.
    Also, for chat users, if users are asked to drop a few messages, users really don’t want to use it anymore. Message reliability is really important.
    The network conditions of the client have not been mentioned yet. The compatibility of the WAP network is flawed, and the protocol under the socket cannot be used at all. . .
    WeChat is really awesome. . .

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 11:29:17

    Recommend pomelo

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 11:29:17

    Same recommendationPomelo, lz I also have the same idea, I would like to try it out when I have some free time.
    What the people above said are good, I will post another tutorial: Tutorial----Distributed Chat Server
    =======Add========
    Well, actually I have done XMPP, which is very complicated and heavy, especially for mobile chat rooms, traffic is a problem. In addition, it is actually good to use Erlang to make messages. It is said that the core of the backend of MiLiao is made of this.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:29:17

    Reference firebase
    https://www.firebase.com/

    reply
    0
  • 黄舟

    黄舟2017-04-17 11:29:17

    https://github.com/xiaowudesign/nowboard There is one that enables online information exchange by logging in through Weibo. Just to give the poster an idea.

    reply
    0
  • 迷茫

    迷茫2017-04-17 11:29:17

    Web can use socket.io (it’s node.js, I can’t say go). There are specific tutorials on how to build a chat room using socket.io and express

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 11:29:17

    Based on xmpp, the server has open source openfire, tigase, etc.

    The web side can use jsjac, strophe, etc.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 11:29:17

    We just implemented one using socket.io, and the cache uses redis

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 11:29:17

    I have written something similar, http://itorr.sinaapp.com/comet/ As long as it can send and receive messages and return new messages in a timely manner, it can be done with php + long connection.
    //Source code to be attached

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 11:29:17

    Many applications use xmpp, it seems

    reply
    0
  • Cancelreply