All Classes Namespaces Functions Variables Groups Pages
WebSocketHandler.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
/* WebSocketHandler.qm Copyright 2013 - 2016 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.12 or better
// require type definitions everywhere
// enable all warnings
namespace WebSocketHandler {
class WebSocketConnection {
public:
public :
WebSocketHandler handler;
const DefaultQueuePollingInterval = 50ms;
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();
};
class WebSocketHandler : public HttpServer::AbstractHttpSocketHandler {
public:
public :
public:
private :
RWLock rwl();
hash ch;
public:
constructor(*HttpServer::AbstractAuthenticator auth) ;
hash handleRequest(hash cx, hash hdr, *data b);
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(string id, data d);
private sendClose(Qore::Socket sock, int code, *string txtmsg);
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...
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:75
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::WebSocketConnection::connectionClosed
connectionClosed()
this method is called by the WebSocketHandler when the connection is closed
WebSocketHandler::WebSocketHandler
the main web socket handler class
Definition: WebSocketHandler.qm.dox.h:145
HttpServer::AbstractHttpSocketHandler
WebSocketHandler::WebSocketHandler::logError
logError(string fmt)
default implementation is empty
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:157
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 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::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