61class ServerSentEventClient :
public Logger::LoggerWrapper,
public ConnectionProvider::OptionHelper,
public DataProvider::DelayedObservable {
65 const DataSerializationSupport = ...;
69 const DefaultTimeout = 15s;
72 const Version =
"1.0";
78 const MaxReconnectRetries = -1;
81 const ReconnectDelay = 2s;
85 Condition sleep_cond();
104 timeout timeout_ms = DefaultTimeout;
107 bool reconnect = False;
144 const SSEEDC_CONTINUE = 1;
147 const SSEEDC_BREAK = 2;
256 hash<auto>
connect(*hash<auto> opts, *reference<hash<auto>> info);
309 hash<auto>
connectIntern(*hash<auto> opts, *reference<hash<auto>> info, *
bool reconnect);
371 setWarningQueue(
int warning_ms,
int warning_bs, Queue queue,
auto arg, timeout min_ms = 1s);
452 disconnectUnlocked();
492 waitTidCleared(
int old_tid);
497 setupDecompression();
537 logArgs(LoggerLevel level,
string message, *softlist<auto> args);
542 logDebug(
string fmt, ...);
547 logInfo(
string fmt, ...);
552 logWarn(
string fmt, ...);
557 logError(
string fmt, ...);
563 hash<auto>
connectUnlocked(*hash<auto> hdr0, *reference<hash<auto>> info, *
bool reconnect);
576class QueuedObserver :
public DataProvider::Observer {
588 update(
string event_id, hash<auto> data_);
string getSafeUrl()
Returns a "safe" URL, without any password info.
clearWarningQueue()
Removes any warning Queue object from the Socket.
hash< auto > connectIntern(*hash< auto > opts, *reference< hash< auto > > info, *bool reconnect)
Connects to the sse server.
string last_event_id
Request Last-Event-Id when connecting.
Definition ServerSentEventClient.qc.dox.h:90
int tid_waiting
Event thread waiting count.
Definition ServerSentEventClient.qc.dox.h:115
hash< auto > connectUnlocked(*hash< auto > hdr0, *reference< hash< auto > > info, *bool reconnect)
Performs the HTTP socket connection to the ServerSentEvent server.
reconnectPostamble()
Executes after a reconnect.
bool isOpen()
returns True if the connection is currently open and active, False if not
clearStats()
Clears performance statistics.
int tid
TID of the event thread; only changed in the log.
Definition ServerSentEventClient.qc.dox.h:112
closingConnection()
Called when the connection is closed.
raiseError(string fmt,...)
throsse an exception due to an error
StringOutputStream ostream
The decompression output stream.
Definition ServerSentEventClient.qc.dox.h:99
reestablishConnection(reference< hash< auto > > info)
Connects to the server when reconnecting.
startReconnect()
Starts a reconnect.
disconnectIntern(*bool destroy)
Disconnect with the given close code.
setWarningQueue(int warning_ms, int warning_bs, Queue queue, auto arg, timeout min_ms=1s)
Sets a Queue object to receive socket warnings.
disconnect()
Disconnect with the given close code.
auto deserializeData(string buf)
Deserializes data received.
observersReady()
Called when all observers have been added to the object.
constructorInit(hash< auto > opts)
Common constructor code.
reconnectPreamble()
Executes before a reconnect.
bool do_reconnect
Flag for a user-initiated reconnect.
Definition ServerSentEventClient.qc.dox.h:135
static Sequence seq()
Connection sequence.
start()
Connects and starts receiving messages.
setEventQueue()
Removes any Queue object so that socket events are no longer added to the Queue.
string url
URL string.
Definition ServerSentEventClient.qc.dox.h:132
destructor()
disconnects the connection and stops the event thread if connected
clearTid()
Clears the tid and stop variables and wakes up any waiting threads.
constructor(hash< auto > opts)
Creates the ServerSentEvent client object from the arguments.
hash< auto > getSchemes()
returns a hash of URL scheme information for URL schemes supported by this object
bool getReconnect()
Returns the value of the reconnect flag.
*code start_thread
callable value to start a new thread; must take a callable object as a parameter and return an intege...
Definition ServerSentEventClient.qc.dox.h:126
Condition tid_cond()
Event thread condition variable.
string getUrl()
returns the URL given in the constructor
string content_encoding
The content encoding used by the server.
Definition ServerSentEventClient.qc.dox.h:96
doReconnect()
Handles reconnections.
int num_connects
Total number of connections made.
Definition ServerSentEventClient.qc.dox.h:129
bool chunked
Flag indicating chunked transfer encoding.
Definition ServerSentEventClient.qc.dox.h:93
TransformOutputStream dstream
The decompression transform stream.
Definition ServerSentEventClient.qc.dox.h:102
hash< auto > connect(*hash< auto > opts, *reference< hash< auto > > info)
Connects to the sse server.
stopEvents()
Called to stop generating events.
bool isReconnecting()
Returns True if the client is reconnecting.
int getConnectionId()
returns the unique connection ID
bool reconnect()
Initiate a server reconnect immediately.
string getSerialization()
Returns the data serialization value ("none", "json")
*string getPassword()
Returns any password set for the connection.
*code yield
callable object to yield the current thread's execution
Definition ServerSentEventClient.qc.dox.h:124
int handleEvent(hash< SseMessageInfo > event)
Handles messages.
setEventQueue(Qore::Thread::Queue queue, auto arg, *bool with_data)
Sets a Queue object to receive socket events.
*hash< auto > getConnectionInfo()
Returns information about the current connection.
string serialization
data serialization option: json or none
Definition ServerSentEventClient.qc.dox.h:138
*string getUsername()
Returns any username set for the connection.
hash< auto > getUsageInfo()
Returns performance statistics for the socket.
unsupportedSerialization()
Throws an UNSUPPORTED-SERIALIZATION error.
const Version
Client version.
Definition ServerSentEventClient.qc.dox.h:72
the ServerSentEventClient namespace contains all the definitions in the ServerSentEventClient module
Definition ServerSentEventClient.qc.dox.h:26
const EVENT_SSE_CLOSED
ServerSentEvent connection closed event constant.
Definition ServerSentEventClient.qc.dox.h:39
const SseDefaultPort
default port for connections
Definition ServerSentEventClient.qc.dox.h:28
const EVENT_SSE_CONNECTED
ServerSentEvent connected event type.
Definition ServerSentEventClient.qc.dox.h:44
const EVENT_SSE_DATA
ServerSentEvent data event constant.
Definition ServerSentEventClient.qc.dox.h:34