mapserver/server/static/js/WebsocketChannel.js

22 lines
493 B
JavaScript
Raw Normal View History

2019-01-29 10:57:35 +03:00
var WebSocketChannel = (function(){
'use strict';
function connect(){
var wsUrl = location.protocol.replace("http", "ws") + "//" + location.host + location.pathname.substring(0, location.pathname.lastIndexOf("/")) + "/api/ws";
var ws = new WebSocket(wsUrl);
ws.onmessage = function(e){
var event = JSON.parse(e.data);
if (event.type == "rendered-tile"){
RealtimeTileLayer.update(event.data)
}
}
}
return {
connect: connect
};
}());