All Classes Namespaces Functions Variables Groups Pages
WebSocketClient.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
/* WebSocketClient.qm Copyright 2013 - 2016 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;
public:
public :
const DefaultTimeout = 15s;
const Version = "1.0";
const DefaultUserAgent = sprintf("Qore-WebSocketClient/%s", WebSocketClient::Version);
public:
constructor(code cb, hash opts);
hash connect(*hash opts, *reference info);
bool isOpen();
disconnect(int cmd = WSCC_GoingAway);
nothing clearWarningQueue();
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, any arg, timeout min_ms = 1s);
hash getUsageInfo();
clearStats();
private disconnectUnlocked(int cmd = WSCC_GoingAway);
private eventLoop(code callback);
private logInfo(string fmt);
private logError(string fmt);
private logDebug(string fmt);
private sendClose(int code, *string txtmsg);
private hash connectUnlocked(*hash hdr, *reference info);
send(string str);
send(binary bin);
};
};
WSCC_GoingAway
const WSCC_GoingAway
sprintf
string sprintf(string fmt,...)
WebSocketClient::WebSocketClient::setWarningQueue
nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, any arg, timeout min_ms=1s)
Sets a Queue object to receive socket warnings.
WebSocketClient::WebSocketClient::clearWarningQueue
nothing clearWarningQueue()
Removes any warning Queue object from the Socket.
WebSocketClient::WebSocketClient::clearStats
clearStats()
Clears performance statistics.
WebSocketClient::WsSchemes
const WsSchemes
known websocket schemes
Definition: WebSocketClient.qm.dox.h:94
True
const True
binary
binary binary()
WebSocketClient::WebSocketClient::isOpen
bool isOpen()
returns True if the connection is currently open and active, False if not
WebSocketClient::WsDefaultPort
const WsDefaultPort
default port for connections
Definition: WebSocketClient.qm.dox.h:104
False
const False
WebSocketClient::WebSocketClient
the main websocket client class
Definition: WebSocketClient.qm.dox.h:113
WebSocketClient::WebSocketClient::constructor
constructor(code cb, hash opts)
creates the object and optionally sets logging targets
WebSocketClient::WebSocketClient::disconnect
disconnect(int cmd=WSCC_GoingAway)
disconnect with the given close code
hash
hash hash(object obj)
WebSocketClient::WebSocketClient::getUsageInfo
hash getUsageInfo()
Returns performance statistics for the socket.
WebSocketClient::WebSocketClient::connect
hash connect(*hash opts, *reference info)
connects to the websocket server