Skip to content

Instantly share code, notes, and snippets.

@cons0ul
Created November 21, 2012 09:39
Show Gist options
  • Save cons0ul/4124000 to your computer and use it in GitHub Desktop.
Save cons0ul/4124000 to your computer and use it in GitHub Desktop.
client side websocket implemenenation
wsURL="ws://172.16.205.1"
var ws;
function _init_ws_log(startFunc,port)
{
wsURL = "ws://172.16.205.1"
wsURL = wsURL+":"+port+"/log";
if (wsURL) {
ws = new WebSocket(wsURL,"echo-protocol");
ws.onopen = function(evt) {
log = function(s) { ws.send(s + "\n"); }
iddx=getindex()
startFunc(iddx)
};
ws.onclose = function(evt) {
setTimeout(function(){ _init_ws_log(startFunc,port);},0);return;
};
ws.onmessage = function(evt) { }
//consoleDumpln("Socked received: " + evt.data); };
ws.onerror = function(evt) {};
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment