!7 static Set webSockets = synchroHashSet(); static long counter; p { replaceCollection(webSockets, subBot_getMyWebSockets()); print("Have " + n2(webSockets, "web socket") + "."); doEvery(1000, f count); } html { ret loadJQuery() + "Counting:" + hdiv("", id := 'results) + hreconnectingWebSockets() + hjavascript([[ var ws = new ReconnectingWebSocket("${URI}"); ws.onmessage = function(event) { var d = event.data; $("#results").html(d); }; ]].replace("${URI}", subBot_myWebSocketURI()); } svoid count { ++counter; if (empty(webSockets)) ret; print("Sending " + counter + " to " + n2(webSockets, "socket")); for (O ws : webSockets) pcall(ws, 'send, str(counter)); } static void onNewWebSocket(O ws, S uri) { print("New web socket!"); webSockets.add(ws); } static void onWebSocketMessage(O ws, S msg) { print("Got message: " + msg); } static void onWebSocketClosed(O ws) { print("Closed web socket"); webSockets.remove(ws); }