Qore WebSocketClient Module Reference  1.6.1
WebSocketClient.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 /* WebSocketClient.qm Copyright 2013 - 2017 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 
106 namespace WebSocketClient {
109  const WsSchemes = (
110  "ws": (
111  "ssl": False,
112  ),
113  "wss": (
114  "ssl": True,
115  ),
116  );
117 
119  const WsDefaultPort = 80;
120 
122 
132 
133 public:
134  private :
135  Mutex m();
136  HTTPClient hc;
137  int stop = 0;
138  Counter c();
139  code callback;
140  *code log;
141  *code errlog;
142  *code debuglog;
143  timeout timeout_ms = DefaultTimeout;
145  int cid = -1;
147  *code yield;
148 
149  static Sequence seq();
150 
151 public:
152 
153  public :
155  const DefaultTimeout = 15s;
156 
158  const Version = "1.6";
159 
161  const DefaultUserAgent = sprintf("Qore-WebSocketClient/%s", WebSocketClient::Version);
162 
163 public:
164 
166 
188  constructor(code cb, hash opts);
189 
190 
192  destructor();
193 
194 
196  int getConnectionId();
197 
198 
200  hash getSchemes();
201 
202 
204 
230  hash connect(*hash opts, *reference<hash> info);
231 
232 
234  bool isOpen();
235 
236 
238  disconnect(int cmd = WSCC_GoingAway);
239 
240 
242 
251  nothing clearWarningQueue();
252 
253 
255 
285  nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms = 1s);
286 
287 
289 
307  hash getUsageInfo();
308 
309 
311 
320  clearStats();
321 
322 
323 
324 private:
325  disconnectUnlocked(int cmd = WSCC_GoingAway);
326 public:
327 
328 
329 
330 private:
331  eventLoop(code callback);
332 public:
333 
334 
335 
336 private:
337  logInfo(string fmt);
338 public:
339 
340 
341 
342 private:
343  logError(string fmt);
344 public:
345 
346 
347 
348 private:
349  logDebug(string fmt);
350 public:
351 
352 
353 
354 private:
355  sendClose(int code, *string txtmsg);
356 public:
357 
358 
359 
360 private:
361  hash connectUnlocked(*hash hdr, *reference<hash> info);
362 public:
363 
364 
366 
368  pong();
369 
370 
372 
377  send(string str);
378 
379 
381 
386  send(binary bin);
387 
388  };
389 
391 
406 
407 public:
409 
416  constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh) ;
417 
418 
420  string getType();
421 
422 
424 
432 
433 
435 
446 private:
447  WebSocketClient getImpl(bool connect = True, *hash rtopts);
448 public:
449 
450 
452  hash getOptions();
453 
454 
457 
458 
459 
460 private:
461  hash<PingInfo> pingIntern(hash<PingInfo> rv);
462 public:
463 
464 
466  static WebSocketConnectionObject make(string name, string desc, string url, bool monitor, *hash opts, hash urlh);
467  };
468 };
const WSCC_GoingAway
string sprintf(string fmt,...)
*hash getRuntimeOptions()
returns runtime options
const WsSchemes
known websocket schemes
Definition: WebSocketClient.qm.dox.h:109
const True
*code yield
callable object to yield the current thread&#39;s execution
Definition: WebSocketClient.qm.dox.h:147
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:119
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:405
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:107
WebSocketClient getImpl(bool connect=True, *hash rtopts)
returns a WebSocketClient object
hash hash(object obj)