All Classes Namespaces Functions Variables Groups Pages
WebSocketClient.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
/* WebSocketClient.qm Copyright 2013 - 2014 Qore Technologies, sro
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.
*/
// this module requires Qore 0.8.9 or better
// require type definitions everywhere
// enable all warnings
/* Version History
* 2014-02-04 v1.1: David Nichols <david@qore.org>
+ added socket instrumention support from Qore 0.8.9
* 2013-10-04 v1.0: David Nichols <david@qore.org>
+ the initial version of the WebSocketClient module
*/
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 callback, 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:82
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:92
False
const False
WebSocketClient::WebSocketClient
the main websocket client class
Definition: WebSocketClient.qm.dox.h:101
WebSocketClient::WebSocketClient::constructor
constructor(code callback, 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