mqtt_cpp
Public Member Functions | Friends | List of all members
session_state Struct Reference

#include <session_state.hpp>

Public Member Functions

 session_state (as::io_context &ioc, sub_con_map &subs_map, shared_target &shared_targets, con_sp_t con, buffer client_id, optional< will > will, optional< std::chrono::steady_clock::duration > will_expiry_interval, optional< std::chrono::steady_clock::duration > session_expiry_interval=nullopt)
 
 session_state (session_state &&)=default
 
 ~session_state ()
 
bool online () const
 
template<typename SessionExpireHandler >
void become_offline (SessionExpireHandler &&h)
 
void renew_session_expiry (optional< std::chrono::steady_clock::duration > v)
 
std::shared_ptr< as::steady_timer > const & tim_session_expiry () const
 
void publish (as::io_context &ioc, buffer pub_topic, buffer contents, publish_options pubopts, v5::properties props)
 
void deliver (as::io_context &ioc, buffer pub_topic, buffer contents, publish_options pubopts, v5::properties props)
 
void clean ()
 
void exactly_once_start (packet_id_t packet_id)
 
bool exactly_once_processing (packet_id_t packet_id) const
 
void exactly_once_finish (packet_id_t packet_id)
 
template<typename PublishRetainHandler >
void subscribe (buffer share_name, buffer topic_filter, subscribe_options subopts, PublishRetainHandler &&h, optional< std::size_t > sid=nullopt)
 
void unsubscribe (buffer const &share_name, buffer const &topic_filter)
 
void unsubscribe_all ()
 
void update_will (as::io_context &ioc, optional< MQTT_NS::will > will, optional< std::chrono::steady_clock::duration > will_expiry_interval)
 
void reset_will ()
 
void insert_inflight_message (store_message_variant msg, any life_keeper, std::shared_ptr< as::steady_timer > tim_message_expiry)
 
void send_inflight_messages ()
 
void erase_inflight_message_by_expiry (std::shared_ptr< as::steady_timer > const &sp)
 
void erase_inflight_message_by_packet_id (packet_id_t packet_id)
 
void send_all_offline_messages ()
 
void send_offline_messages_by_packet_id_release ()
 
buffer const & client_id () const
 
void reset_con ()
 
void reset_con (con_sp_t con)
 
con_sp_t const & con () const
 
optional< std::chrono::steady_clock::duration > session_expiry_interval () const
 
optional< MQTT_NS::will > & will ()
 
optional< MQTT_NS::will > const & will () const
 
std::shared_ptr< as::steady_timer > & get_tim_will_expiry ()
 

Friends

class session_states
 

Detailed Description

http://docs.oasis-open.org/mqtt/mqtt/v5.0/cs02/mqtt-v5.0-cs02.html#_Session_State

4.1 Session State In order to implement QoS 1 and QoS 2 protocol flows the Client and Server need to associate state with the Client Identifier, this is referred to as the Session State. The Server also stores the subscriptions as part of the Session State. The session can continue across a sequence of Network Connections. It lasts as long as the latest Network Connection plus the Session Expiry Interval. The Session State in the Server consists of: · The existence of a Session, even if the rest of the Session State is empty. · The Clients subscriptions, including any Subscription Identifiers. · QoS 1 and QoS 2 messages which have been sent to the Client, but have not been completely acknowledged. · QoS 1 and QoS 2 messages pending transmission to the Client and OPTIONALLY QoS 0 messages pending transmission to the Client. · QoS 2 messages which have been received from the Client, but have not been completely acknowledged. · The Will Message and the Will Delay Interval · If the Session is currently not connected, the time at which the Session will end and Session State will be discarded.

Retained messages do not form part of the Session State in the Server, they are not deleted as a result of a Session ending.

Constructor & Destructor Documentation

◆ session_state() [1/2]

session_state::session_state ( as::io_context &  ioc,
sub_con_map subs_map,
shared_target shared_targets,
con_sp_t  con,
buffer  client_id,
optional< will will,
optional< std::chrono::steady_clock::duration >  will_expiry_interval,
optional< std::chrono::steady_clock::duration >  session_expiry_interval = nullopt 
)
inline

◆ session_state() [2/2]

session_state::session_state ( session_state &&  )
default

◆ ~session_state()

session_state::~session_state ( )
inline

Member Function Documentation

◆ become_offline()

template<typename SessionExpireHandler >
void session_state::become_offline ( SessionExpireHandler &&  h)
inline

◆ clean()

void session_state::clean ( )
inline

◆ client_id()

buffer const& session_state::client_id ( ) const
inline

◆ con()

con_sp_t const& session_state::con ( ) const
inline

◆ deliver()

void session_state::deliver ( as::io_context &  ioc,
buffer  pub_topic,
buffer  contents,
publish_options  pubopts,
v5::properties  props 
)
inline

◆ erase_inflight_message_by_expiry()

void session_state::erase_inflight_message_by_expiry ( std::shared_ptr< as::steady_timer > const &  sp)
inline

◆ erase_inflight_message_by_packet_id()

void session_state::erase_inflight_message_by_packet_id ( packet_id_t  packet_id)
inline

◆ exactly_once_finish()

void session_state::exactly_once_finish ( packet_id_t  packet_id)
inline

◆ exactly_once_processing()

bool session_state::exactly_once_processing ( packet_id_t  packet_id) const
inline

◆ exactly_once_start()

void session_state::exactly_once_start ( packet_id_t  packet_id)
inline

◆ get_tim_will_expiry()

std::shared_ptr<as::steady_timer>& session_state::get_tim_will_expiry ( )
inline

◆ insert_inflight_message()

void session_state::insert_inflight_message ( store_message_variant  msg,
any  life_keeper,
std::shared_ptr< as::steady_timer >  tim_message_expiry 
)
inline

◆ online()

bool session_state::online ( ) const
inline

◆ publish()

void session_state::publish ( as::io_context &  ioc,
buffer  pub_topic,
buffer  contents,
publish_options  pubopts,
v5::properties  props 
)
inline

◆ renew_session_expiry()

void session_state::renew_session_expiry ( optional< std::chrono::steady_clock::duration >  v)
inline

◆ reset_con() [1/2]

void session_state::reset_con ( )
inline

◆ reset_con() [2/2]

void session_state::reset_con ( con_sp_t  con)
inline

◆ reset_will()

void session_state::reset_will ( )
inline

◆ send_all_offline_messages()

void session_state::send_all_offline_messages ( )
inline

◆ send_inflight_messages()

void session_state::send_inflight_messages ( )
inline

◆ send_offline_messages_by_packet_id_release()

void session_state::send_offline_messages_by_packet_id_release ( )
inline

◆ session_expiry_interval()

optional<std::chrono::steady_clock::duration> session_state::session_expiry_interval ( ) const
inline

◆ subscribe()

template<typename PublishRetainHandler >
void session_state::subscribe ( buffer  share_name,
buffer  topic_filter,
subscribe_options  subopts,
PublishRetainHandler &&  h,
optional< std::size_t >  sid = nullopt 
)
inline

◆ tim_session_expiry()

std::shared_ptr<as::steady_timer> const& session_state::tim_session_expiry ( ) const
inline

◆ unsubscribe()

void session_state::unsubscribe ( buffer const &  share_name,
buffer const &  topic_filter 
)
inline

◆ unsubscribe_all()

void session_state::unsubscribe_all ( )
inline

◆ update_will()

void session_state::update_will ( as::io_context &  ioc,
optional< MQTT_NS::will will,
optional< std::chrono::steady_clock::duration >  will_expiry_interval 
)
inline

◆ will() [1/2]

optional<MQTT_NS::will>& session_state::will ( )
inline

◆ will() [2/2]

optional<MQTT_NS::will> const& session_state::will ( ) const
inline

Friends And Related Function Documentation

◆ session_states

friend class session_states
friend

The documentation for this struct was generated from the following file: