Tracks WebSocket connections, topic indexes, and broadcasts change events.
More...
#include <ws.h>
Tracks WebSocket connections, topic indexes, and broadcasts change events.
Thread-safe. One instance is owned by MbSSEMgr and shares the SSE cleanup loop via cleanupStaleConnections.
◆ MbWSMgr()
◆ ~MbWSMgr()
| mb::MbWSMgr::~MbWSMgr |
( |
| ) |
|
|
default |
◆ addConnection()
| void mb::MbWSMgr::addConnection |
( |
const drogon::WebSocketConnectionPtr & | conn, |
|
|
RealtimeWsSession | session ) |
Register a new connection and its session snapshot. Closes with 1008 if at capacity.
◆ broadcastChange()
| void mb::MbWSMgr::broadcastChange |
( |
const json & | change_event | ) |
|
Deliver a formatted change event to all connections subscribed to the matching topic.
◆ cleanupStaleConnections()
| void mb::MbWSMgr::cleanupStaleConnections |
( |
const MantisBase & | app, |
|
|
std::chrono::steady_clock::time_point | now ) |
Close expired, idle, or connect-only sessions.
- Parameters
-
| app | Application instance (auth expiry checks). |
| now | Current steady clock time (shared with SSE cleanup). |
◆ connectionCount()
| size_t mb::MbWSMgr::connectionCount |
( |
| ) |
|
- Returns
- Number of active WebSocket sessions.
◆ getSession()
| RealtimeWsSession * mb::MbWSMgr::getSession |
( |
const drogon::WebSocketConnectionPtr & | conn | ) |
|
- Returns
- Mutable session for a connection, or nullptr if unknown.
◆ removeConnection()
| void mb::MbWSMgr::removeConnection |
( |
const drogon::WebSocketConnectionPtr & | conn | ) |
|
Remove connection from topic indexes and session map.
◆ setTopics()
| void mb::MbWSMgr::setTopics |
( |
const drogon::WebSocketConnectionPtr & | conn, |
|
|
const std::vector< std::string > & | topics ) |
Replace the connection's topic set (subscribe replaces, does not merge).
◆ unsubscribe()
| void mb::MbWSMgr::unsubscribe |
( |
const drogon::WebSocketConnectionPtr & | conn, |
|
|
const std::vector< std::string > & | topics ) |
Remove specific topics from a connection without affecting others.
The documentation for this class was generated from the following files:
- /home/runner/work/mantisbase/mantisbase/include/mantisbase/core/ws.h
- /home/runner/work/mantisbase/mantisbase/src/core/realtime_ws.cpp