Qore WebSocketHandler Module Reference  1.4
WebSocketHandler.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 /* WebSocketHandler.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 // this module requires Qore 0.8.13 or better
26 
27 // require type definitions everywhere
28 
29 // enable all warnings
30 
31 
32 
33 
71 namespace WebSocketHandler {
74 
83 
84 public:
85  public :
86  WebSocketHandler handler;
87 
88  // wait a maximum of 1/2 second for data
89  const DefaultQueuePollingInterval = 500ms;
90 
91 public:
92 
93  private :
96 
97 public:
98 
100  constructor(WebSocketHandler n_handler);
101 
102 
104  *binary pollData();
105 
106 
109 
110 
112  sendEncoded(binary msg);
113 
114 
116  send(data msg);
117 
118 
120 
122  gotMessage(string msg);
123 
124 
126 
128  gotMessage(binary msg);
129 
130 
132 
135 
136 
138 
141  registered();
142 
143  };
144 
146 
161 
162 public:
163  public :
164  // default socket send timeout
165  const DefaultSocketSendTimeout = 30s;
166 
167 public:
168 
169  private :
171  RWLock rwl();
172 
175 
176 public:
177 
179 
182 
183 
185 
209  hash handleRequest(hash cx, hash hdr, *data b);
210 
211 
213 
215  *list getConnectionIds();
216 
217 
219 
233  startImpl(softstring lid, hash cx, hash hdr, Qore::Socket sock);
234 
235 
237  WebSocketConnection getConnectionImpl(hash cx, hash hdr, string cid);
238 
239 
241  deregisterConnectionImpl(WebSocketConnection wsc);
242 
243 
245 
247  sendAll(data d);
248 
249 
251 
255  sendOne(softstring id, data d);
256 
257 
258 
259 private:
260  sendClose(Qore::Socket sock, int code, *string txtmsg);
261 public:
262 
263 
264  static string getDataString(*data data);
265 
267  logInfo(string fmt);
268 
269 
271  logError(string fmt);
272 
273 
275  logDebug(string fmt);
276 
277  };
278 };
*binary pollData()
this method is called by the WebSocketHandler to poll for messages from the client to send from the s...
this class represents a connection to a websocket client
Definition: WebSocketHandler.qm.dox.h:82
binary binary()
*binary pollDataImmediate()
this method is called by the WebSocketHandler to poll for messages from the client to send from the s...
list list(...)
connectionClosed()
this method is called by the WebSocketHandler when the connection is closed
the WebSocketHandler namespace contains all the objects in the WebSocketHandler module ...
Definition: WebSocketHandler.qm.dox.h:72
send(data msg)
pushes an unencoded message on the connection's message queue; the message will be encoded with WebSo...
hash ch
connection hash
Definition: WebSocketHandler.qm.dox.h:174
registered()
called when the connection has been registered in handler and accept sending messages (e...
gotMessage(string msg)
this method is called by the WebSocketHandler when messages from the client are received ...
hash hash(object obj)
Qore::Thread::Queue queue()
the Queue object stores messages to be sent to the server
constructor(WebSocketHandler n_handler)
the constructor is called by the WebSocketHandler when a new connection is made by a websocket client...
sendEncoded(binary msg)
pushes an already-encoded message on the connection's message queue