!include once #1015699 // websocket static WebSocketClient webSocketOnMessage(S url, final VF1 onMessage) { ret webSocketOnMessage(url, onMessage, null); } static WebSocketClient webSocketOnMessage(S url, final VF1 onMessage, fS initialMessage, fO... args) ctex { WebSocketClient client = new WebSocketClient(new URI(url)) { public void onMessage(S s) { if (!licensed()) ret with close(); // program exit // s = dropTrailingNullChars(s); // older server bug pcallF(onMessage, s); } public void onOpen(ServerHandshake handshake) { if (nempty(initialMessage)) send(format(initialMessage, args)); } public void onClose(int code, S reason, bool remote) {} public void onError(Exception e) { printStackTrace(e); } }; client.connect(); ret client; }