Qore WebSocketClient Module Reference  1.7

Introduction to the WebSocketClient Module

The WebSocketClient module provides client support for RFC-6455 based WebSocket protocol implementations in Qore.

To use this module, use "%requires WebSocketClient" in your code.

This module automatically uses the WebSocketUtil module for encoding and decoding web socket messages.

All the public symbols in the module are defined in the WebSocketClient namespace.

Currently the module provides the following classes:

Example

#!/usr/bin/env qore
%new-style
%enable-all-warnings
%requires WebSocketClient
*string url = shift ARGV;
if (!url) {
stderr.printf("usage: %s <URL>\n", get_script_name());
exit(1);
}
WebSocketClient ws();
ws.connect(("url": url, "callback": sub (*data d) { if (d.typeCode() == NT_BINARY) printf("binary msg received: %y\n", d); else if (d) printf("%s\n", d);}));
# wait forever (or until ctrl-c)
Counter c(1);
c.waitForZero();

WebSocketClient Module Release History

v1.7

v1.6.3

  • added missing exception handling in the connection close callback (issue 3225)

v1.6.2

  • allowed the handling of PING messages to be customized (issue 2887)

v1.6.1

v1.6

v1.5

v1.4

  • fixed a bug parsing and generating the websocket close status code (issue 1216)

v1.3

  • ignore SOCKET-NOT-OPEN errors when closing (server already closed the connection)

v1.2

  • prepend "WebSocketClient: " to log messages

v1.1

  • added socket instrumention support from Qore 0.8.9

v1.0