Mercurial > code > home > repos > homeauto
view service/wallscreen/websocket.js @ 1143:d1bc88f67969
RgbPixelsAnimation and docker build updates
Ignore-this: c79e4a64bb5ad8683aa837839e79785b
darcs-hash:bcc0201b2aaf3a1f1f689a6437eef8298970c58a
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sat, 03 Mar 2018 18:09:34 -0800 |
parents | a99b4d5afb83 |
children |
line wrap: on
line source
// from the light9/rdfdb one function reconnectingWebSocket(url, onMessage) { var pong = 0; function connect() { var ws = new WebSocket(url); ws.onopen = function() { $("#status").text(""); }; ws.onerror = function(e) { $("#status").text("error: "+e); }; ws.onclose = function() { pong = 1 - pong; $("#status").text("disconnected (retrying "+(pong ? "😼":"😺")+")"); setTimeout(connect, 2000); }; ws.onmessage = function (evt) { onMessage(JSON.parse(evt.data)); }; } connect(); }