@@ -367,6 +367,39 @@ public Object wsConnect(String anURL, NativeFunction onConnect, NativeFunction o
367367 return WebSockets .wsConnect (authenticator , l , p , anURL , onConnect , onMsg , onError , onClose , aTimeout , supportSelfSigned );
368368 }
369369
370+ /**
371+ * <odoc>
372+ * <key>HTTP.wsClient(anURL, onConnect, onMsg, onError, onClose, aTimeout, supportSelfSigned) : WebSocketsReply</key>
373+ * Tries to establish a websocket connection (ws or wss) and returns a jetty WebSocketClient java object.
374+ * As callbacks you should defined onConnect, onMsg, onError and onClose. The onConnect callback will
375+ * provide, as argument, the created session that you should use to send data; the onMsg callback will
376+ * provide, as arguments, aType (either "text" or "bytes"), aPayload (string or array of bytes) and an offset
377+ * and length (in case type is "bytes"); the onError callback will provide the cause; the onClose callback
378+ * will provide aStatusCode and aReason. You can optionally provide aTimeout (number) and indicate if self signed SSL
379+ * certificates should be accepted (supportSelfSigned = true). Example:\
380+ * \
381+ * plugin("HTTP");\
382+ * var session; var output = "";\
383+ * var res = (new HTTP()).wsClient("ws://echo.websocket.org",\
384+ * function(aSession) { log("Connected"); session = aSession; },\
385+ * function(aType, aPayload, aOffset, aLength) { if (aType == "text") output += aPayload; },\
386+ * function(aCause) { logErr(aCause); },\
387+ * function(aStatusCode, aReason) { log("Closed (" + aReason + ")"); }\
388+ * );\
389+ * session.getRemote().sendString("Hello World!");\
390+ * while(output.length < 1) { sleep(100); };\
391+ * res.client.stop();\
392+ * print(output);\
393+ * \
394+ * NOTE: this functionality is only available if used with JVM >= 1.8\
395+ * \
396+ * </odoc>
397+ */
398+ @ JSFunction
399+ public Object wsClient (String anURL , NativeFunction onConnect , NativeFunction onMsg , NativeFunction onError , NativeFunction onClose , Object aTimeout , boolean supportSelfSigned ) throws Exception {
400+ return WebSockets .wsClient (authenticator , l , p , anURL , onConnect , onMsg , onError , onClose , aTimeout , supportSelfSigned );
401+ }
402+
370403 /**
371404 *
372405 * @param aURL
0 commit comments