MantisBase v0.4.9
Loading...
Searching...
No Matches
mb::MbSSEMgr Class Reference

Manages SSE routes, sessions, broadcast, and shared WebSocket cleanup. More...

#include <sse.h>

Inheritance diagram for mb::MbSSEMgr:
Collaboration diagram for mb::MbSSEMgr:

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ MbSSEMgr()

mb::MbSSEMgr::MbSSEMgr ( const MantisBase & app)
explicit

◆ ~MbSSEMgr()

mb::MbSSEMgr::~MbSSEMgr ( )

Member Function Documentation

◆ broadcastChange()

void mb::MbSSEMgr::broadcastChange ( const json & change_event)

Push a change event to all SSE sessions subscribed to the matching topic.

◆ createRoutes()

void mb::MbSSEMgr::createRoutes ( )

Register GET/POST /api/v1/realtime and the WebSocket controller.

◆ createSession()

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.

Returns
Client ID (rt_sse_...), or empty on failure.

◆ fetchSession()

std::shared_ptr< MbSSESession > mb::MbSSEMgr::fetchSession ( const std::string & session_id)

Look up a session by ID without updating activity.

◆ getSession()

std::shared_ptr< MbSSESession > mb::MbSSEMgr::getSession ( const std::string & sessionId)

Look up a session by client ID (used by POST subscribe handler).

◆ getSessionCount()

size_t mb::MbSSEMgr::getSessionCount ( )
Returns
Number of active SSE sessions.

◆ isRunning()

bool mb::MbSSEMgr::isRunning ( ) const
nodiscard

◆ removeSession()

void mb::MbSSEMgr::removeSession ( const std::string & session_id)

Remove and close a session by client ID.

◆ start()

void mb::MbSSEMgr::start ( )

Start the cleanup background thread.

◆ stop()

void mb::MbSSEMgr::stop ( )

Stop cleanup and the realtime worker.

◆ updateActivity()

void mb::MbSSEMgr::updateActivity ( const std::string & session_id)

Bump last-activity for an existing session.

◆ wsMgr()

MbWSMgr & mb::MbSSEMgr::wsMgr ( ) const
Returns
WebSocket manager (shared cleanup loop).

The documentation for this class was generated from the following files:
  • /home/runner/work/mantisbase/mantisbase/include/mantisbase/core/sse.h
  • /home/runner/work/mantisbase/mantisbase/src/core/sse_mgr.cpp