WebSocketClient.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
/* WebSocketClient.qm Copyright 2013 - 2017 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// minimum required Qore version
// require type definitions everywhere
// enable all warnings
namespace WebSocketClient {
const WsSchemes = (
"ws": (
"ssl": False,
),
"wss": (
"ssl": True,
),
);
const WsDefaultPort = 80;
class WebSocketClient {
public:
private :
Mutex m();
HTTPClient hc;
int stop = 0;
Counter c();
code callback;
*code log;
*code errlog;
*code debuglog;
timeout timeout_ms = DefaultTimeout;
int cid = -1;
*code yield;
static Sequence seq();
public:
public :
const DefaultTimeout = 15s;
const Version = "1.6";
const DefaultUserAgent = sprintf("Qore-WebSocketClient/%s", WebSocketClient::Version);
public:
constructor(code cb, hash opts);
destructor();
int getConnectionId();
hash getSchemes();
hash connect(*hash opts, *reference<hash> info);
bool isOpen();
disconnect(int cmd = WSCC_GoingAway);
nothing clearWarningQueue();
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms = 1s);
hash getUsageInfo();
clearStats();
private:
disconnectUnlocked(int cmd = WSCC_GoingAway);
public:
private:
eventLoop(code callback);
public:
private:
logInfo(string fmt);
public:
private:
logError(string fmt);
public:
private:
logDebug(string fmt);
public:
private:
sendClose(int code, *string txtmsg);
public:
private:
hash connectUnlocked(*hash hdr, *reference<hash> info);
public:
pong();
send(string str);
send(binary bin);
};
class WebSocketConnectionObject : public ConnectionProvider::AbstractConnection {
public:
constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh) ;
string getType();
*hash getRuntimeOptions();
private:
WebSocketClient getImpl(bool connect = True, *hash rtopts);
public:
hash getOptions();
*hash getDefaultOptions();
private:
hash<PingInfo> pingIntern(hash<PingInfo> rv);
public:
static WebSocketConnectionObject make(string name, string desc, string url, bool monitor, *hash opts, hash urlh);
};
};
WSCC_GoingAway
const WSCC_GoingAway
ConnectionProvider::AbstractConnection::monitor
bool monitor
sprintf
string sprintf(string fmt,...)
WebSocketClient::WebSocketConnectionObject::getRuntimeOptions
*hash getRuntimeOptions()
returns runtime options
WebSocketClient::WsSchemes
const WsSchemes
known websocket schemes
Definition: WebSocketClient.qm.dox.h:109
ConnectionProvider::AbstractConnection::opts
*hash opts
True
const True
WebSocketClient::WebSocketClient::yield
*code yield
callable object to yield the current thread&#39;s execution
Definition: WebSocketClient.qm.dox.h:147
ConnectionProvider::AbstractConnection::name
string name
binary
binary binary()
WebSocketClient::WebSocketConnectionObject::constructor
constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh)
creates the WebSocketConnectionObject object
WebSocketClient::WsDefaultPort
const WsDefaultPort
default port for connections
Definition: WebSocketClient.qm.dox.h:119
ConnectionProvider::AbstractConnection::urlh
hash urlh
False
const False
WebSocketClient::WebSocketConnectionObject::getType
string getType()
returns "websocket"
ConnectionProvider::AbstractConnection
WebSocketClient::WebSocketConnectionObject
class for websocket connections; returns an object of class WebSocketClient for receiving websocket e...
Definition: WebSocketClient.qm.dox.h:405
WebSocketClient::WebSocketConnectionObject::make
static WebSocketConnectionObject make(string name, string desc, string url, bool monitor, *hash opts, hash urlh)
static constructor
WebSocketClient::WebSocketConnectionObject::getOptions
hash getOptions()
gets options
ConnectionProvider::AbstractConnection::desc
string desc
WebSocketClient::WebSocketConnectionObject::getDefaultOptions
*hash getDefaultOptions()
returns default options
WebSocketClient
the WebSocketClient namespace contains all the definitions in the WebSocketClient module ...
Definition: WebSocketClient.qm.dox.h:107
WebSocketClient::WebSocketConnectionObject::getImpl
WebSocketClient getImpl(bool connect=True, *hash rtopts)
returns a WebSocketClient object
ConnectionProvider::AbstractConnection::url
string url
hash
hash hash(object obj)