Adding Server Side Events Support in Internet Explorer and old Browsers

Jeanfrancois Arcand edited this page Jul 25, 2013 · 3 revisions

FAQ

Step by Step Tutorials

Concepts & Architecture

15 Minutes Tutorial

Advanced Topics

API

Known WebServer Issues

References

External Documentations

githalytics.com alpha

Clone this wiki locally

The Server Side Events(SSE) specification is not supported by Internet Explorer or old Browsers. Starting with Atmosphere 2.0, You can emulate the sse transport by adding Remy's Sharp EventSource.js to your Javascript:

<!DOCTYPE html>

<script type="text/javascript" src="js/EventSource.js"></script>
<script type="text/javascript" src="js/atmosphere.js"></script>
<script type="text/javascript" src="js/application.js"></script>

<html>

<head>
    <meta charset="utf-8">
    <title>Atmosphere Chat</title>

In your application.js, just do the normal stuff

$(function () {
    "use strict";

    var content = $('#content');
    var input = $('#input');
    var status = $('#status');
    var myName = false;
    var author = null;
    var logged = false;
    var socket = $.atmosphere;
    var request = { url: document.location.toString() + 'chat',
                    contentType : "application/json",
                    logLevel : 'debug',
                    transport : 'sse' ,
                    fallbackTransport: 'long-polling'};


    request.onOpen = function(response) {
        content.html($('<p>', { text: 'Atmosphere connected using ' + response.transport }));
        input.removeAttr('disabled').focus();
        status.text('Choose name:');
    };
...

The Atmosphere's server side component, via the SSEAtmosphereInterceptor, will support this Javascript's polyfills. For example, download or build the sse-chat sample to see it in action.