WebSocketHandler.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
/* WebSocketHandler.qm Copyright 2013 - 2017 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// this module requires Qore 0.8.13 or better
// require type definitions everywhere
// enable all warnings
namespace WebSocketHandler {
class WebSocketConnection {
public:
public :
WebSocketHandler handler;
// wait a maximum of 1/2 second for data
const DefaultQueuePollingInterval = 500ms;
public:
private :
Qore::Thread::Queue queue();
public:
constructor(WebSocketHandler n_handler);
*binary pollData();
*binary pollDataImmediate();
sendEncoded(binary msg);
send(data msg);
gotMessage(string msg);
gotMessage(binary msg);
connectionClosed();
registered();
};
class WebSocketHandler : public HttpServer::AbstractHttpSocketHandler {
public:
public :
// default socket send timeout
const DefaultSocketSendTimeout = 30s;
public:
private :
RWLock rwl();
hash ch;
public:
constructor(*HttpServer::AbstractAuthenticator auth) ;
hash handleRequest(hash cx, hash hdr, *data b);
*list getConnectionIds();
startImpl(softstring lid, hash cx, hash hdr, Qore::Socket sock);
WebSocketConnection getConnectionImpl(hash cx, hash hdr, string cid);
deregisterConnectionImpl(WebSocketConnection wsc);
sendAll(data d);
sendOne(softstring id, data d);
private:
sendClose(Qore::Socket sock, int code, *string txtmsg);
public:
static string getDataString(*data data);
logInfo(string fmt);
logError(string fmt);
logDebug(string fmt);
};
};
WebSocketHandler::WebSocketConnection::pollData
*binary pollData()
this method is called by the WebSocketHandler to poll for messages from the client to send from the s...
Qore::Socket
WebSocketHandler::WebSocketConnection
this class represents a connection to a websocket client
Definition: WebSocketHandler.qm.dox.h:85
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...
list
list list(...)
HttpServer::AbstractAuthenticator
WebSocketHandler::WebSocketConnection::connectionClosed
connectionClosed()
this method is called by the WebSocketHandler when the connection is closed
WebSocketHandler
the WebSocketHandler namespace contains all the objects in the WebSocketHandler module ...
Definition: WebSocketHandler.qm.dox.h:75
HttpServer::AbstractHttpSocketHandler
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::ch
hash ch
connection hash
Definition: WebSocketHandler.qm.dox.h:177
WebSocketHandler::WebSocketConnection::registered
registered()
called when the connection has been registered in handler and accept sending messages (e...
WebSocketHandler::WebSocketConnection::gotMessage
gotMessage(string msg)
this method is called by the WebSocketHandler when messages from the client are received ...
hash
hash hash(object obj)
WebSocketHandler::WebSocketConnection::queue
Qore::Thread::Queue queue()
the Queue object stores messages to be sent to the server
WebSocketHandler::WebSocketConnection::constructor
constructor(WebSocketHandler n_handler)
the constructor is called by the WebSocketHandler when a new connection is made by a websocket client...
WebSocketHandler::WebSocketConnection::sendEncoded
sendEncoded(binary msg)
pushes an already-encoded message on the connection&#39;s message queue