How to push messages in real time?

Source: Internet
Author: User
For example, when segmentfault pushes a message, the Bell will have a red number. after the message is clicked, there will be a new message, which can be implemented without refreshing the page or using ajax, what should I do?

For example, segmentfault message push

When there is a message, the Bell will have a red number. after the message is clicked, there will be a new message, which can be implemented without refreshing the page and ajax. what should we do?

Reply content:

For example, segmentfault message push

When there is a message, the Bell will have a red number. after the message is clicked, there will be a new message, which can be implemented without refreshing the page and ajax. what should we do?

Websocket

I used fiddle to check whether socket. io was used.
Tutorial 1 use Node. js + Socket. IO to build a real-time WebSocket application

It should be websocket. you can look at the workerman framework and practice websocket.
Workerman

If you considerphpUpstairs.
Also recommendedpomelo, Distributed and stable, that is, steep curves.

I am working on WEB push recently. I can provide you with some solutions:

Generally, if the real-time requirements for messages are not very high, such as checking a message in 10 seconds is acceptable, then the simplest polling solution can be used, that is, an interface is requested from the server at a certain time to obtain whether unread messages exist. this method is quite simple and has good compatibility with browsers.

There is also a widely used method, that is, webSocket, which has been mentioned before. I will not talk about it more.

HTML5 has a new push standard. SSE (Server-Side Event) can be used for real-time push, which is easier to implement than websocket, but the support for browsers is not very good (modern browsers can support, but IE and Edge are not supported ).

Currently, the mature server push solution is jsonp.

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.