Qore WebSocketClient Module Reference  1.6.2
WebSocketClient.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 /* WebSocketClient.qm Copyright 2013 - 2018 Qore Technologies, s.r.o.
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23 */
24 
25 // minimum required Qore version
26 
27 // require type definitions everywhere
28 
29 // enable all warnings
30 
31 
32 
33 
110 namespace WebSocketClient {
113  const WsSchemes = (
114  "ws": (
115  "ssl": False,
116  ),
117  "wss": (
118  "ssl": True,
119  ),
120  );
121 
123  const WsDefaultPort = 80;
124 
126 
136 
137 public:
138  private :
139  Mutex m();
140  HTTPClient hc;
141  int stop = 0;
142  Counter c();
143  code callback;
144  *code log;
145  *code errlog;
146  *code debuglog;
147  timeout timeout_ms = DefaultTimeout;
149  int cid = -1;
151  *code yield;
152 
153  static Sequence seq();
154 
155 public:
156 
157  public :
159  const DefaultTimeout = 15s;
160 
162  const Version = "1.6";
163 
165  const DefaultUserAgent = sprintf("Qore-WebSocketClient/%s", WebSocketClient::Version);
166 
167 public:
168 
170 
192  constructor(code cb, hash opts);
193 
194 
196  destructor();
197 
198 
200  int getConnectionId();
201 
202 
204  hash getSchemes();
205 
206 
208 
234  hash connect(*hash opts, *reference<hash> info);
235 
236 
238  bool isOpen();
239 
240 
242  disconnect(int cmd = WSCC_GoingAway);
243 
244 
246 
255  nothing clearWarningQueue();
256 
257 
259 
289  nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms = 1s);
290 
291 
293 
311  hash getUsageInfo();
312 
313 
315 
324  clearStats();
325 
326 
327 
328 private:
329  disconnectUnlocked(int cmd = WSCC_GoingAway);
330 public:
331 
332 
333 
334 private:
335  eventLoop(code callback);
336 public:
337 
338 
339 
340 private:
341  handlePing(hash<auto> h);
342 public:
343 
344 
345 
346 private:
347  logInfo(string fmt);
348 public:
349 
350 
351 
352 private:
353  logError(string fmt);
354 public:
355 
356 
357 
358 private:
359  logDebug(string fmt);
360 public:
361 
362 
363 
364 private:
365  sendClose(int code, *string txtmsg);
366 public:
367 
368 
369 
370 private:
371  hash connectUnlocked(*hash hdr, *reference<hash> info);
372 public:
373 
374 
376 
378  pong();
379 
380 
382 
387  send(string str);
388 
389 
391 
396  send(binary bin);
397 
398  };
399 
401 
416 
417 public:
419 
426  constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh) ;
427 
428 
430  string getType();
431 
432 
434 
442 
443 
445 
456 private:
457  WebSocketClient getImpl(bool connect = True, *hash rtopts);
458 public:
459 
460 
462  hash getOptions();
463 
464 
467 
468 
469 
470 private:
471  hash<PingInfo> pingIntern(hash<PingInfo> rv);
472 public:
473 
474 
476  static WebSocketConnectionObject make(string name, string desc, string url, bool monitor, *hash opts, hash urlh);
477  };
478 };
const WSCC_GoingAway
string sprintf(string fmt,...)
*hash getRuntimeOptions()
returns runtime options
const WsSchemes
known websocket schemes
Definition: WebSocketClient.qm.dox.h:113
const True
*code yield
callable object to yield the current thread&#39;s execution
Definition: WebSocketClient.qm.dox.h:151
binary binary()
constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh)
creates the WebSocketConnectionObject object
const WsDefaultPort
default port for connections
Definition: WebSocketClient.qm.dox.h:123
const False
string getType()
returns "websocket"
class for websocket connections; returns an object of class WebSocketClient for receiving websocket e...
Definition: WebSocketClient.qm.dox.h:415
static WebSocketConnectionObject make(string name, string desc, string url, bool monitor, *hash opts, hash urlh)
static constructor
*hash getDefaultOptions()
returns default options
the WebSocketClient namespace contains all the definitions in the WebSocketClient module ...
Definition: WebSocketClient.qm.dox.h:111
WebSocketClient getImpl(bool connect=True, *hash rtopts)
returns a WebSocketClient object
hash hash(object obj)