Server Push in Javascript

I would like to use server side push based on atmosphere in Javascript access the state of an item. Could anyone point me to working example.
The code below that I have found seems not to work.

<header><title>This is title</title></header>
<script src=""></script>
var socket = atmosphere;
var request = new atmosphere.AtmosphereRequest();
request = {
    url: "http://martin-pc:8080/rest/items/Window_FF_Bed_nord?type=json",
    contentType: "application/json",
    header: {"Accept": "application/json"},
    trackMessageLength: true,
    shared: true,
    transport: 'websocket',
    logLevel : 'debug',
    fallbackTransport: 'long-polling'};

request.onOpen = function (response) {"opOpen");

request.onMessage = function (message) {"onMessage", message);;
request.onError = function(response) {"Error");

var subSocket = socket.subscribe(request);

Testing Servicer side push

Hi Martin,

Been working on this myself and just got it working reliably.

If you haven’t already done so you need yo download atmosphere.js and add a line

from the url: line remove ?type=json

everything else looks OK.

Hope this helps.


the line to add was the script src pointing to atmosphere.js

Hi Roy,
Thanks for answering my problem.

It seems to work great and big thanks but the atmosphere.js seems to be polled (?) very often.
I thought that only a change on the server would be doing this.
As a consequence I am seeing a 50-60% load on Firefox on a single item.
Currently I testing with OH2.

I have been using the following link to atmosphere.js.

Is there a better source?