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

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)

Detailed Description

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.

Constructor & Destructor Documentation

◆ MbSSESession()

mb::MbSSESession::MbSSESession ( std::string client_id,
const std::set< std::string > & topics,
drogon::ResponseStreamPtr stream,
RealtimeAuthSnapshot auth = makeGuestAuthSnapshot() )

Member Function Documentation

◆ authSnapshot() [1/2]

mb::RealtimeAuthSnapshot & mb::MbSSESession::authSnapshot ( )
nodiscard

◆ authSnapshot() [2/2]

const mb::RealtimeAuthSnapshot & mb::MbSSESession::authSnapshot ( ) const
nodiscard

◆ close()

void mb::MbSSESession::close ( )

Close the stream and mark the session inactive.

◆ formatEvent()

mb::json mb::MbSSESession::formatEvent ( const json & change_event) const

Format a raw DB change row into the public SSE change event shape.

◆ getClientID()

const std::string & mb::MbSSESession::getClientID ( ) const
nodiscard

◆ getConnectedAt()

std::chrono::steady_clock::time_point mb::MbSSESession::getConnectedAt ( ) const
nodiscard

◆ getLastActivity()

std::chrono::steady_clock::time_point mb::MbSSESession::getLastActivity ( ) const
nodiscard

◆ getTopics()

std::set< std::string > mb::MbSSESession::getTopics ( ) const
nodiscard

◆ isActive()

bool mb::MbSSESession::isActive ( ) const
nodiscard

◆ isInterestedIn()

bool mb::MbSSESession::isInterestedIn ( const json & change_event) const
Returns
true if this session should receive the given change event.

◆ sendEvent()

bool mb::MbSSESession::sendEvent ( const std::string & eventType,
const json & data )

Send an SSE frame (event: + data:). Returns false if the stream is closed.

◆ setAuthSnapshot()

void mb::MbSSESession::setAuthSnapshot ( mb::RealtimeAuthSnapshot auth)

Update auth after a successful subscribe-time upgrade.

◆ setTopics()

void mb::MbSSESession::setTopics ( const std::set< std::string > & topics)

Replace the full topic set (subscribe replaces prior subscriptions).

◆ updateActivity()

void mb::MbSSESession::updateActivity ( )

Bump last-activity timestamp (keepalive and idle tracking).

◆ updateTopics()

void mb::MbSSESession::updateTopics ( const std::set< std::string > & topics)

Replace topics (legacy alias; prefer setTopics).


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_session.cpp