Stackoverflow technology for push message?

when I have a notification in my top menu a small icon appears, now I'm trying to understand how SOF does it. I think it could be using AJAX, which checks the server every second, which makes sense, but with 1000+ users it will overload the servers, I think someone can tell me if I'm right, and let me know how I can use technology like live-click SOF without hacking the server

+3
source share
2 answers

You should learn WebSocket technology . It will work with the latest browsers (Chrome, Firefox and Safari) and allow the server to make changes to the browser. However, it is not supported by Internet Explorer, so Ajax polling is almost the only option for this browser.

+4
source

I recommend using Source Source, unlike AJAX Comet, there is no open open connection, so you are much more capable of transferring more clients.

/* Event Source Code */
// Initial Startup
if (!!window.EventSource) {
    var source = new EventSource('EventSource.php');
    // Native EventSource Events
    source.addEventListener('open', function(e) {
        // Connection was opened.
    }, false);
    source.addEventListener('error', function(e) {
        if (e.readyState == EventSource.CLOSED) {
            // Connection was closed.
        }
    }, false);
    source.addEventListener('message', function(e) {
        // You'll have to make your own banner function here.
        // e.data, this is what you'll need.
    }, false);
}
0
source

All Articles