Qore WebSocketHandler Module Reference 1.0

- Main Page
- Related Pages
- Namespaces
- Classes

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
52 namespace WebSocketHandler {
55
63 class WebSocketConnection {
64
65 public:
66 public :
67 WebSocketHandler handler;
68
69 const DefaultQueuePollingInterval = 50ms;
70
71 public:
72
73 private :
75 Qore::Thread::Queue queue();
76
77 public:
78
80 constructor(WebSocketHandler handler);
81
82
84 *binary pollData();
85
86
88 *binary pollDataImmediate();
89
90
92 sendEncoded(binary msg);
93
94
96 send(data msg);
97
98
100 gotMessage(string msg);
101
102
104 gotMessage(binary msg);
105
106 };
107
109
123 class WebSocketHandler : public HttpServer::AbstractHttpSocketHandler {
124
125 public:
126 public :
127
128 public:
129
130 private :
132 RWLock rwl();
133
135 hash ch;
136
137 public:
138
140
142 constructor(*HttpServer::AbstractAuthenticator auth);
143
144
146
170 hash handleRequest(hash cx, hash hdr, *data b);
171
172
174
188 startImpl(softstring lid, hash cx, hash hdr, Qore::Socket sock);
189
190
192 WebSocketConnection getConnectionImpl(hash cx, hash hdr, string cid);
193
194
196 deregisterConnectionImpl(WebSocketConnection wsc);
197
198
200
202 sendAll(data d);
203
204
206
210 sendOne(string id, data d);
211
212
213
214 private:
215 sendClose(Qore::Socket sock, int code, *string txtmsg);
216 public:
217
218
219 static string getDataString(*data data);
220
222 logInfo(string fmt);
223
224
226 logError(string fmt);
227
228
230 logDebug(string fmt);
231
232 };
233 };
WebSocketHandler::WebSocketConnection::pollData
*binary pollData()
this method is called by the WebSocketHandler to poll for messages from the client to send from the s...
HttpServer::AbstractHttpRequestHandler::auth
*AbstractAuthenticator auth
Qore::Socket
WebSocketHandler::WebSocketHandler::logDebug
logDebug(string fmt)
default implementation is empty
WebSocketHandler::WebSocketConnection
this class represents a connection to a websocket client
Definition: WebSocketHandler.qm.dox.h:63
binary
binary binary()
WebSocketHandler::WebSocketConnection::pollDataImmediate
*binary pollDataImmediate()
this method is called by the WebSocketHandler to poll for messages from the client to send from the s...
WebSocketHandler::WebSocketHandler::handleRequest
hash handleRequest(hash cx, hash hdr, *data b)
called by the HTTP server to handle incoming HTTP requests
HttpServer::AbstractAuthenticator
WebSocketHandler::WebSocketHandler::deregisterConnectionImpl
deregisterConnectionImpl(WebSocketConnection wsc)
called when the connection terminates; the default implementation does nothing
WebSocketHandler::WebSocketHandler::getConnectionImpl
WebSocketConnection getConnectionImpl(hash cx, hash hdr, string cid)
called when a connection is established; the default implementation creates a WebSocketConnection obj...
WebSocketHandler::WebSocketHandler::startImpl
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...
WebSocketHandler::WebSocketHandler::sendAll
sendAll(data d)
sends a message to all connected clients
WebSocketHandler::WebSocketHandler
the main web socket handler class
Definition: WebSocketHandler.qm.dox.h:123
HttpServer::AbstractHttpSocketHandler
WebSocketHandler::WebSocketHandler::logError
logError(string fmt)
default implementation is empty
WebSocketHandler::WebSocketConnection::constructor
constructor(WebSocketHandler handler)
the constructor is called by the WebSocketHandler when a new connection is made by a websocket client...
Qore::Thread::Queue
WebSocketHandler::WebSocketConnection::send
send(data msg)
pushes an unencoded message on the connection&#39;s message queue; the message will be encoded with WebSo...
WebSocketHandler::WebSocketHandler::rwl
RWLock rwl()
connection read-write lock
WebSocketHandler::WebSocketHandler::ch
hash ch
connection hash
Definition: WebSocketHandler.qm.dox.h:135
WebSocketHandler::WebSocketConnection::gotMessage
gotMessage(string msg)
this method is called by the WebSocketHandler when messages from the client are received ...
WebSocketHandler::WebSocketHandler::constructor
constructor(*HttpServer::AbstractAuthenticator auth)
create the object optionally with the given AbstractAuthenticator
WebSocketHandler::WebSocketHandler::sendOne
sendOne(string id, data d)
sends a message to the given connection ID
hash
hash hash(object obj)
WebSocketHandler::WebSocketConnection::queue
Qore::Thread::Queue queue()
the Queue object stored messages to be sent to the server
WebSocketHandler::WebSocketHandler::logInfo
logInfo(string fmt)
default implementation is empty
WebSocketHandler::WebSocketConnection::sendEncoded
sendEncoded(binary msg)
pushes an already-encoded message on the connection&#39;s message queue