Qore WebSocketClient Module Reference  1.2
 All Classes Namespaces Files Functions Variables Modules Pages

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 class:

Example

#!/usr/bin/env qore
%require-our
%enable-all-warnings
%requires WebSocketClient
my *string $url = shift $ARGV;
if (!$url) {
stderr.printf("usage: %s <URL>\n", get_script_name());
exit(1);
}
my 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)
my Counter $c(1);
$c.waitForZero();