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.

<html>
<header><title>This is title</title></header>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<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) {
    console.info("opOpen");
};


request.onMessage = function (message) {
    console.info("onMessage", message);
    console.info(JSON.parse(message.responseBody));
};
    
	
request.onError = function(response) {
	console.info("Error");
 };

var subSocket = socket.subscribe(request);


</script>
Testing Servicer side push
</body>
</html>

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.

Roy

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?