Qore WebSocketHandler Module Reference  1.0
 All Classes Namespaces Functions Variables Groups Pages
WebSocketHandler.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 /* WebSocketHandler.qm Copyright 2013 Qore Technologies, sro
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.8 or better
26 
27 // require type definitions everywhere
28 
29 // enable all warnings
30 
31 
32 
33 /* Version History
34  * 2013-10-04 v1.0: David Nichols <david@qore.org>
35  + the initial version of the WebSocketHandler module
36 */
37 
54 namespace WebSocketHandler {
57 
66 
67 public:
68  public :
69  WebSocketHandler handler;
70 
71  const DefaultQueuePollingInterval = 50ms;
72 
73 public:
74 
75  private :
78 
79 public:
80 
83 
84 
86  *binary pollData();
87 
88 
91 
92 
94  sendEncoded(binary msg);
95 
96 
98  send(data msg);
99 
100 
102  gotMessage(string msg);
103 
104 
106  gotMessage(binary msg);
107 
108  };
109 
111 
126 
127 public:
128  public :
129 
130 public:
131 
132  private :
134  RWLock rwl();
135 
138 
139 public:
140 
142 
145 
146 
148 
172  hash handleRequest(hash cx, hash hdr, *data b);
173 
174 
176 
190  startImpl(softstring lid, hash cx, hash hdr, Qore::Socket sock);
191 
192 
194  WebSocketConnection getConnectionImpl(hash cx, hash hdr, string cid);
195 
196 
199 
200 
202 
204  sendAll(data d);
205 
206 
208 
212  sendOne(string id, data d);
213 
214 
215  private sendClose(Qore::Socket sock, int code, *string txtmsg);
216 
217 
218  static string getDataString(*data data);
219 
221  logInfo(string fmt);
222 
223 
225  logError(string fmt);
226 
227 
229  logDebug(string fmt);
230 
231  };
232 };
*binary pollData()
this method is called by the WebSocketHandler to poll for messages from the client to send from the s...
logDebug(string fmt)
default implementation is empty
this class represents a connection to a websocket client
Definition: WebSocketHandler.qm.dox.h:65
binary binary()
*binary pollDataImmediate()
this method is called by the WebSocketHandler to poll for messages from the client to send from the s...
hash handleRequest(hash cx, hash hdr, *data b)
called by the HTTP server to handle incoming HTTP requests
deregisterConnectionImpl(WebSocketConnection wsc)
called when the connection terminates; the default implementation does nothing
WebSocketConnection getConnectionImpl(hash cx, hash hdr, string cid)
called when a connection is established; the default implementation creates a WebSocketConnection obj...
startImpl(softstring lid, hash cx, hash hdr, Qore::Socket sock)
called from the HTTP server after the handleRequest() method indicates that a dedicated connection sh...
sendAll(data d)
sends a message to all connected clients
the main web socket handler class
Definition: WebSocketHandler.qm.dox.h:125
logError(string fmt)
default implementation is empty
constructor(WebSocketHandler handler)
the constructor is called by the WebSocketHandler when a new connection is made by a websocket client...
send(data msg)
pushes an unencoded message on the connection&#39;s message queue; the message will be encoded with WebSo...
RWLock rwl()
connection read-write lock
hash ch
connection hash
Definition: WebSocketHandler.qm.dox.h:137
gotMessage(string msg)
this method is called by the WebSocketHandler when messages from the client are received ...
constructor(*HttpServer::AbstractAuthenticator auth)
create the object optionally with the given AbstractAuthenticator
sendOne(string id, data d)
sends a message to the given connection ID
hash hash(object obj)
Qore::Thread::Queue queue()
the Queue object stored messages to be sent to the server
logInfo(string fmt)
default implementation is empty
sendEncoded(binary msg)
pushes an already-encoded message on the connection&#39;s message queue