search

Home  >  Q&A  >  body text

java - How are the instant messaging system and push notification system implemented?

How to forward a message to the specified other end through the server

If it is convenient, post a typical code

In addition, what information is stored when the session is stored?

PHP中文网PHP中文网2726 days ago900

reply all(6)I'll reply

  • 黄舟

    黄舟2017-06-12 09:29:28

    My understanding:
    The client makes a request (sends a request) to the server every interval (such as one second).
    If there is a message on the server, the information is marked in the response (response) to notify the client that there is a new message on the server.
    The client sends a request to the server to pull the message, and the server responds.

    request: Any new news? Please reply if received.
    response:No.
    request: Any new news? Please reply if received.
    response:No.
    request: Any new news? Please reply if received.
    response: Yes, the message ID is 123456.
    request: Please send the message content with message ID 123456.
    response: Message id: 123456, message text: Surprise! This woman actually did such a thing in front of 1.3 billion people...

    reply
    0
  • 迷茫

    迷茫2017-06-12 09:29:28

    Message transmission is obtained by refreshing the client to the server instead of the server sending it directly to the client

    In the past, there were indeed some cases where the server directly opened a port locally and the server directly requested the client, but now it is rare to use it for message push (usually used to transfer files or information within the LAN)

    The session is stored on the server, and the name and id of the SESSION are stored locally through Cookies. The server uses these two to obtain the content stored on the server side

    reply
    0
  • 滿天的星座

    滿天的星座2017-06-12 09:29:28

    There are currently two common solutions.
    1. The client actively polls (that is, it asks the server every N times if there is any news.
    2. The server actively pushes. Sockets are used between back-end services, and websockets can be used to communicate with the front-end.

    reply
    0
  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-06-12 09:29:28

    http2.0 can handle it very well, you can try it~

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-06-12 09:29:28

    It is said that it is instant, and a long connection must be established. Such as socket.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-06-12 09:29:28

    If it is just one of the many functions of the product, instant messaging recommends that the subject connect to IM, which can save a lot of development expenses. The functions provided by the existing IM providers are relatively comprehensive, and it is much more cost-effective than developing it yourself. You can take a look at the environmental information http://www.easemob.com/

    reply
    0
  • Cancelreply