![]() |
MantisBase v0.4.9
|
Per-client SSE session state and async stream writer. More...
#include <sse.h>
Public Member Functions | |
| MbSSESession (std::string client_id, const std::set< std::string > &topics, drogon::ResponseStreamPtr stream, RealtimeAuthSnapshot auth=makeGuestAuthSnapshot()) | |
| bool | sendEvent (const std::string &eventType, const json &data) |
| bool | isInterestedIn (const json &change_event) const |
| json | formatEvent (const json &change_event) const |
| void | updateActivity () |
| void | updateTopics (const std::set< std::string > &topics) |
| std::chrono::steady_clock::time_point | getLastActivity () const |
| std::chrono::steady_clock::time_point | getConnectedAt () const |
| void | close () |
| bool | isActive () const |
| const std::string & | getClientID () const |
| std::set< std::string > | getTopics () const |
| void | setTopics (const std::set< std::string > &topics) |
| RealtimeAuthSnapshot & | authSnapshot () |
| const RealtimeAuthSnapshot & | authSnapshot () const |
| void | setAuthSnapshot (RealtimeAuthSnapshot auth) |
Per-client SSE session state and async stream writer.
Holds subscribed topics, auth snapshot, activity timestamps, and a Drogon drogon::ResponseStreamPtr for zero-thread event delivery.
| mb::MbSSESession::MbSSESession | ( | std::string | client_id, |
| const std::set< std::string > & | topics, | ||
| drogon::ResponseStreamPtr | stream, | ||
| RealtimeAuthSnapshot | auth = makeGuestAuthSnapshot() ) |
|
nodiscard |
|
nodiscard |
| void mb::MbSSESession::close | ( | ) |
Close the stream and mark the session inactive.
Format a raw DB change row into the public SSE change event shape.
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
| bool mb::MbSSESession::isInterestedIn | ( | const json & | change_event | ) | const |
| bool mb::MbSSESession::sendEvent | ( | const std::string & | eventType, |
| const json & | data ) |
Send an SSE frame (event: + data:). Returns false if the stream is closed.
| void mb::MbSSESession::setAuthSnapshot | ( | mb::RealtimeAuthSnapshot | auth | ) |
Update auth after a successful subscribe-time upgrade.
| void mb::MbSSESession::setTopics | ( | const std::set< std::string > & | topics | ) |
Replace the full topic set (subscribe replaces prior subscriptions).
| void mb::MbSSESession::updateActivity | ( | ) |
Bump last-activity timestamp (keepalive and idle tracking).
| void mb::MbSSESession::updateTopics | ( | const std::set< std::string > & | topics | ) |
Replace topics (legacy alias; prefer setTopics).