!7 static Set webSockets = synchroHashSet(); static long counter; p { doEvery(1000, f count); } html { int port = subBot_currentPort(); ret "Counting:" + hdiv(id := 'results) + hreconnectingWebSockets() + hjavascript([[ var ws = new ReconnectingWebSocket("${URI}"); ws.onmessage = function(event) { var d = event.data; $("#results").append(d + "
"); }; ]].replace("${URI}", subBot_myWebSocketURI()); } svoid count { ++counter; 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); }