Transpiled version (3104L) is out of date.
sS hInitSecondaryWebSocket(O... _) { optPar S wsVar = "ws2"; optPar S url; if (empty(url)) fail("Need URL for secondary websocket"); optPar S onOpen; optPar S onMessage; optPar S readyMsg = "WebSocket 2 ready!"; ret hreconnectingWebSockets() + hscript([[ var ws2Ready = false; var ws2InitialMsgs = []; var ws2Verbose = false; var ]] + wsVar + [[ = new ReconnectingWebSocket(]] + jsQuote(url) + [[); ]] + wsVar + [[.onopen = function(event) { ws2Ready = true; console.log(]] + jsQuote(readyMsg) + [[); ws2InitialMsgs.forEach(function(msg) { if (ws2Verbose) console.log("Sending initial msg to websocket 2: " + msg); ws2.send(msg); }); ]] + jsDropTrailingComments(onOpen) + [[ }; ]] + wsVar + [[.onmessage = function(event) { ]] + unnull(onMessage) + [[ }; // add an initial message to send when websocket opens // also send it now if ws is open already function ws2InitialMsg(msg) { ws2InitialMsgs.push(msg); if (ws2Ready) { if (ws2Verbose) console.log("Sending initial msg to websocket 2: " + msg); ws2.send(msg); } } ]]); }
Began life as a copy of #1029959
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030367 |
Snippet name: | hInitSecondaryWebSocket |
Eternal ID of this version: | #1030367/4 |
Text MD5: | 3ccafa24dd2b733d65869a724abfe7d6 |
Author: | stefan |
Category: | javax / html |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-12-09 18:26:37 |
Source code size: | 1285 bytes / 38 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 172 / 250 |
Version history: | 3 change(s) |
Referenced in: | [show references] |