![]() |
MantisBase v0.4.9
|
Manages SSE routes, sessions, broadcast, and shared WebSocket cleanup. More...
#include <sse.h>


Public Member Functions | |
| MbSSEMgr (const MantisBase &app) | |
| ~MbSSEMgr () | |
| void | createRoutes () |
| std::string | createSession (const std::set< std::string > &initial_topics, drogon::ResponseStreamPtr stream, RealtimeAuthSnapshot auth=makeGuestAuthSnapshot()) |
| Create a session and attach it to an async response stream. | |
| std::shared_ptr< MbSSESession > | fetchSession (const std::string &session_id) |
| void | removeSession (const std::string &session_id) |
| void | updateActivity (const std::string &session_id) |
| std::shared_ptr< mb::MbSSESession > | getSession (const std::string &sessionId) |
| void | broadcastChange (const json &change_event) |
| size_t | getSessionCount () |
| MbWSMgr & | wsMgr () const |
| void | start () |
| void | stop () |
| bool | isRunning () const |
| Public Member Functions inherited from mb::MbAppMixin | |
| MbAppMixin (const MantisBase &app) | |
| Constrictor for instantiating this interface. | |
| MbAppMixin (MbAppMixin &&)=default | |
| MbAppMixin & | operator= (MbAppMixin &&)=delete |
| MbAppMixin (const MbAppMixin &)=default | |
| MbAppMixin & | operator= (const MbAppMixin &)=delete |
| const MantisBase & | mbApp () const |
| Application that owns this service or request context. | |
| const MbLogger & | logger () const |
Manages SSE routes, sessions, broadcast, and shared WebSocket cleanup.
Owns a MbWSMgr instance and runs a background thread that closes expired, idle, and connect-only sessions for both SSE and WebSocket.
|
explicit |
| mb::MbSSEMgr::~MbSSEMgr | ( | ) |
| void mb::MbSSEMgr::broadcastChange | ( | const json & | change_event | ) |
Push a change event to all SSE sessions subscribed to the matching topic.
| void mb::MbSSEMgr::createRoutes | ( | ) |
Register GET/POST /api/v1/realtime and the WebSocket controller.
| std::string mb::MbSSEMgr::createSession | ( | const std::set< std::string > & | initial_topics, |
| drogon::ResponseStreamPtr | stream, | ||
| RealtimeAuthSnapshot | auth = makeGuestAuthSnapshot() ) |
Create a session and attach it to an async response stream.
| std::shared_ptr< MbSSESession > mb::MbSSEMgr::fetchSession | ( | const std::string & | session_id | ) |
Look up a session by ID without updating activity.
| std::shared_ptr< MbSSESession > mb::MbSSEMgr::getSession | ( | const std::string & | sessionId | ) |
Look up a session by client ID (used by POST subscribe handler).
| size_t mb::MbSSEMgr::getSessionCount | ( | ) |
|
nodiscard |
| void mb::MbSSEMgr::removeSession | ( | const std::string & | session_id | ) |
Remove and close a session by client ID.
| void mb::MbSSEMgr::start | ( | ) |
Start the cleanup background thread.
| void mb::MbSSEMgr::stop | ( | ) |
Stop cleanup and the realtime worker.
| void mb::MbSSEMgr::updateActivity | ( | const std::string & | session_id | ) |
Bump last-activity for an existing session.
| MbWSMgr & mb::MbSSEMgr::wsMgr | ( | ) | const |