| Qore ServerSentEventHandler Module Reference 1.0.2

Loading...
Searching...
No Matches
ServerSentEventConnection.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* ServerSentEventConnection.qc Copyright 2025 Qore Technologies, s.r.o.
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
26 namespace ServerSentEventHandler {
28
37 class ServerSentEventConnection {
38
39 public:
41 ServerSentEventHandler handler;
42
44 hash<auto> cx;
45
47 hash<auto> hdr;
48
50 string cid;
51
53 bool stop_flag = False;
54
55 // wait a maximum of 1/4 second for data
56 const DefaultQueuePollingInterval = 250ms;
57
58 protected:
60 Qore::Thread::Queue queue();
61
63 int tid = gettid();
64
65 public:
66
67 private:
69 Socket sock;
70
71 public:
72
74
78 constructor(ServerSentEventHandler handler, Socket sock, hash<auto> cx, hash<auto> hdr, string cid);
79
80
82
84 *string pollData();
85
86
88
90 *string pollDataImmediate();
91
92
94 sendEncoded(string msg);
95
96
98
100 send(hash<SseMessageInfo> msg);
101
102
104
108 connectionClosed();
109
110
112
114 registered();
115
116
118
120 flush();
121
122
124 stop();
125
126};
127};
Qore::Thread::Queue
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