MantisBase v0.3.4
Loading...
Searching...
No Matches
mb::SSESession Class Reference

#include <sse.h>

Public Member Functions

 SSESession (const std::string &sessionId, const std::set< std::string > &topics, const json &auth=json::object(), const json &verification=json::object())
 
void queueEvent (const std::string &eventType, const json &data)
 
bool waitForEvent (std::string &eventType, json &data, std::chrono::milliseconds timeout)
 
bool isInterestedIn (const json &change_event) const
 
json formatEvent (const json &change_event) const
 
void updateActivity ()
 
void updateTopics (std::set< std::string > &topics)
 
auto getLastActivity () const
 
void close ()
 
bool isActive () const
 
const std::string & getClientID () const
 
const std::set< std::string > & getTopics () const
 
void setTopics (const std::set< std::string > &topics)
 

Detailed Description

Per-client SSE session: holds subscribed topics, auth details, and queues events (change, ping).

Constructor & Destructor Documentation

◆ SSESession()

mb::SSESession::SSESession ( const std::string &  sessionId,
const std::set< std::string > &  topics,
const json auth = json::object(),
const json verification = json::object() 
)

Member Function Documentation

◆ close()

void mb::SSESession::close ( )

Mark session inactive and wake any waiters (disconnect).

◆ formatEvent()

mb::json mb::SSESession::formatEvent ( const json change_event) const

Format a change event for SSE (topic, action, entity, row_id, data, timestamp).

◆ getClientID()

const std::string & mb::SSESession::getClientID ( ) const

◆ getLastActivity()

auto mb::SSESession::getLastActivity ( ) const

◆ getTopics()

const std::set< std::string > & mb::SSESession::getTopics ( ) const

◆ isActive()

bool mb::SSESession::isActive ( ) const

◆ isInterestedIn()

bool mb::SSESession::isInterestedIn ( const json change_event) const

True if this session is subscribed to the topic implied by change_event.

◆ queueEvent()

void mb::SSESession::queueEvent ( const std::string &  eventType,
const json data 
)

Queue an event (e.g. "change", "ping") to be sent to the client.

◆ setTopics()

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

◆ updateActivity()

void mb::SSESession::updateActivity ( )

◆ updateTopics()

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

◆ waitForEvent()

bool mb::SSESession::waitForEvent ( std::string &  eventType,
json data,
std::chrono::milliseconds  timeout 
)

Block until the next event is available or timeout; returns true if event was read.


The documentation for this class was generated from the following files: