Qore WebSocketClient Module Reference  1.6
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 
103 namespace WebSocketClient {
106  const WsSchemes = (
107  "ws": (
108  "ssl": False,
109  ),
110  "wss": (
111  "ssl": True,
112  ),
113  );
114 
116  const WsDefaultPort = 80;
117 
119 
129 
130 public:
131  private :
132  Mutex m();
133  HTTPClient hc;
134  int stop = 0;
135  Counter c();
136  code callback;
137  *code log;
138  *code errlog;
139  *code debuglog;
140  timeout timeout_ms = DefaultTimeout;
142  int cid = -1;
144  *code yield;
145 
146  static Sequence seq();
147 
148 public:
149 
150  public :
152  const DefaultTimeout = 15s;
153 
155  const Version = "1.6";
156 
158  const DefaultUserAgent = sprintf("Qore-WebSocketClient/%s", WebSocketClient::Version);
159 
160 public:
161 
163 
185  constructor(code cb, hash opts);
186 
187 
189  destructor();
190 
191 
193  int getConnectionId();
194 
195 
197  hash getSchemes();
198 
199 
201 
227  hash connect(*hash opts, *reference<hash> info);
228 
229 
231  bool isOpen();
232 
233 
235  disconnect(int cmd = WSCC_GoingAway);
236 
237 
239 
248  nothing clearWarningQueue();
249 
250 
252 
282  nothing setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms = 1s);
283 
284 
286 
304  hash getUsageInfo();
305 
306 
308 
317  clearStats();
318 
319 
320 
321 private:
322  disconnectUnlocked(int cmd = WSCC_GoingAway);
323 public:
324 
325 
326 
327 private:
328  eventLoop(code callback);
329 public:
330 
331 
332 
333 private:
334  logInfo(string fmt);
335 public:
336 
337 
338 
339 private:
340  logError(string fmt);
341 public:
342 
343 
344 
345 private:
346  logDebug(string fmt);
347 public:
348 
349 
350 
351 private:
352  sendClose(int code, *string txtmsg);
353 public:
354 
355 
356 
357 private:
358  hash connectUnlocked(*hash hdr, *reference<hash> info);
359 public:
360 
361 
363 
368  send(string str);
369 
370 
372 
377  send(binary bin);
378 
379  };
380 
382 
397 
398 public:
400 
407  constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh) ;
408 
409 
411  string getType();
412 
413 
415 
423 
424 
426 
437 private:
438  WebSocketClient getImpl(bool connect = True, *hash rtopts);
439 public:
440 
441 
443  hash getOptions();
444 
445 
448 
449 
450 
451 private:
452  hash<PingInfo> pingIntern(hash<PingInfo> rv);
453 public:
454 
455 
457  static WebSocketConnectionObject make(string name, string desc, string url, bool monitor, *hash opts, hash urlh);
458  };
459 };
const WSCC_GoingAway
string sprintf(string fmt,...)
*hash getRuntimeOptions()
returns runtime options
const WsSchemes
known websocket schemes
Definition: WebSocketClient.qm.dox.h:106
const True
*code yield
callable object to yield the current thread&#39;s execution
Definition: WebSocketClient.qm.dox.h:144
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:116
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:396
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:104
WebSocketClient getImpl(bool connect=True, *hash rtopts)
returns a WebSocketClient object
hash hash(object obj)