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>