Loading...
Searching...
No Matches
ServerSentEventConnection.qc.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
/* ServerSentEventConnection.qc Copyright 2025 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.
*/
namespace ServerSentEventHandler {
class ServerSentEventConnection {
public:
ServerSentEventHandler handler;
hash<auto> cx;
hash<auto> hdr;
string cid;
bool stop_flag = False;
// wait a maximum of 1/4 second for data
const DefaultQueuePollingInterval = 250ms;
protected:
Qore::Thread::Queue queue();
int tid = gettid();
public:
private:
Socket sock;
public:
constructor(ServerSentEventHandler handler, Socket sock, hash<auto> cx, hash<auto> hdr, string cid);
*string pollData();
*string pollDataImmediate();
sendEncoded(string msg);
send(hash<SseMessageInfo> msg);
connectionClosed();
registered();
flush();
stop();
};
};
ServerSentEventHandler::ServerSentEventConnection
this class represents a connection to an HTTP client
Definition ServerSentEventConnection.qc.dox.h:37
ServerSentEventHandler::ServerSentEventConnection::cx
hash< auto > cx
Original request context.
Definition ServerSentEventConnection.qc.dox.h:44
ServerSentEventHandler::ServerSentEventConnection::hdr
hash< auto > hdr
Original request header info.
Definition ServerSentEventConnection.qc.dox.h:47
ServerSentEventHandler::ServerSentEventConnection::connectionClosed
connectionClosed()
This method is called when the connection is closed.
ServerSentEventHandler::ServerSentEventConnection::pollData
*string pollData()
This method is called to poll for messages from the client to send from the server.
ServerSentEventHandler::ServerSentEventConnection::sendEncoded
sendEncoded(string msg)
Pushes an already-encoded message on the connection's message queue.
ServerSentEventHandler::ServerSentEventConnection::constructor
constructor(ServerSentEventHandler handler, Socket sock, hash< auto > cx, hash< auto > hdr, string cid)
the constructor is called when a new connection is made by an HTTP client
ServerSentEventHandler::ServerSentEventConnection::stop
stop()
force closing socket related to connection
ServerSentEventHandler::ServerSentEventConnection::cid
string cid
The connection ID.
Definition ServerSentEventConnection.qc.dox.h:50
ServerSentEventHandler::ServerSentEventConnection::flush
flush()
Flush all output data.
ServerSentEventHandler::ServerSentEventConnection::pollDataImmediate
*string pollDataImmediate()
This method is called to poll for messages to send to the client from the server.
ServerSentEventHandler::ServerSentEventConnection::queue
Qore::Thread::Queue queue()
the Queue object stores messages to be sent to the server
ServerSentEventHandler::ServerSentEventConnection::tid
int tid
The TID of the I/O thread.
Definition ServerSentEventConnection.qc.dox.h:63
ServerSentEventHandler::ServerSentEventConnection::send
send(hash< SseMessageInfo > msg)
Pushes an unencoded message on the connection's message queue.
ServerSentEventHandler::ServerSentEventConnection::handler
ServerSentEventHandler handler
The parent handler object.
Definition ServerSentEventConnection.qc.dox.h:41
ServerSentEventHandler::ServerSentEventConnection::stop_flag
bool stop_flag
Stop connection flag.
Definition ServerSentEventConnection.qc.dox.h:53
ServerSentEventHandler::ServerSentEventConnection::sock
Socket sock
The socket used by the server for this connection.
Definition ServerSentEventConnection.qc.dox.h:69
ServerSentEventHandler::ServerSentEventConnection::registered
registered()
Called when the connection has been registered in handler and accept sending messages.
ServerSentEventHandler
the ServerSentEventHandler namespace contains all the objects in the ServerSentEventHandler module
Definition ServerSentEventConnection.qc.dox.h:26