Twitch SDK (Internal)
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
ttv::PubSubTopicListenerHelper Class Reference

#include <pubsubclient.h>

Inheritance diagram for ttv::PubSubTopicListenerHelper:
ttv::PubSubClient::ITopicListener

Classes

struct  Entry
 

Public Types

enum  State { State::Initialized, State::ShuttingDown, State::Shutdown }
 

Public Member Functions

 PubSubTopicListenerHelper (std::shared_ptr< PubSubClient > pubsub, std::shared_ptr< PubSubClient::ITopicListener > listener)
 
virtual ~PubSubTopicListenerHelper ()
 
State GetState () const
 
PubSubClient::SubscribeState::Enum GetSubscriptionState (const std::string &topic)
 
TTV_ErrorCode Subscribe (const std::string &topic)
 
TTV_ErrorCode Unsubscribe (const std::string &topic)
 
bool ContainsTopic (const std::string &topic) const
 
void Shutdown ()
 
virtual void OnTopicSubscribeStateChanged (PubSubClient *source, const std::string &topic, PubSubClient::SubscribeState::Enum state, TTV_ErrorCode ec) override
 
virtual void OnTopicMessageReceived (PubSubClient *source, const std::string &topic, const json::Value &msg) override
 
virtual void OnTopicListenerRemoved (PubSubClient *source, const std::string &topic, TTV_ErrorCode ec) override
 

Protected Attributes

std::map< std::string, EntrymSubscriptionStates
 
std::shared_ptr< PubSubClientmPubSub
 
std::weak_ptr< PubSubClient::ITopicListenermListener
 
State mState
 

Detailed Description

A helper listener proxy which makes it easier to manage subscription state.


Class Documentation

◆ ttv::PubSubTopicListenerHelper::Entry

struct ttv::PubSubTopicListenerHelper::Entry
Class Members
Enum state
bool subscriptionDesired

Member Enumeration Documentation

◆ State

Enumerator
Initialized 
ShuttingDown 
Shutdown 

Constructor & Destructor Documentation

◆ PubSubTopicListenerHelper()

ttv::PubSubTopicListenerHelper::PubSubTopicListenerHelper ( std::shared_ptr< PubSubClient pubsub,
std::shared_ptr< PubSubClient::ITopicListener listener 
)

◆ ~PubSubTopicListenerHelper()

virtual ttv::PubSubTopicListenerHelper::~PubSubTopicListenerHelper ( )
virtual

Member Function Documentation

◆ ContainsTopic()

bool ttv::PubSubTopicListenerHelper::ContainsTopic ( const std::string &  topic) const

◆ GetState()

State ttv::PubSubTopicListenerHelper::GetState ( ) const
inline

◆ GetSubscriptionState()

PubSubClient::SubscribeState::Enum ttv::PubSubTopicListenerHelper::GetSubscriptionState ( const std::string &  topic)

◆ OnTopicListenerRemoved()

virtual void ttv::PubSubTopicListenerHelper::OnTopicListenerRemoved ( PubSubClient source,
const std::string &  topic,
TTV_ErrorCode  ec 
)
overridevirtual

Indicates the the listener is no longer going to receive topic events and the reference to the listener is removed. This is independent of topic subscription and there could be other registered topic listeners for the same topic.

Implements ttv::PubSubClient::ITopicListener.

◆ OnTopicMessageReceived()

virtual void ttv::PubSubTopicListenerHelper::OnTopicMessageReceived ( PubSubClient source,
const std::string &  topic,
const json::Value msg 
)
overridevirtual

Received a message on a topic.

Implements ttv::PubSubClient::ITopicListener.

◆ OnTopicSubscribeStateChanged()

virtual void ttv::PubSubTopicListenerHelper::OnTopicSubscribeStateChanged ( PubSubClient source,
const std::string &  topic,
PubSubClient::SubscribeState::Enum  state,
TTV_ErrorCode  ec 
)
overridevirtual

Indicates changes to the topic subscription state on the socket. After receiving SubscribeState::Subscribed the client should resync all absolute state in order for deltas to properly apply to the local data.

Implements ttv::PubSubClient::ITopicListener.

◆ Shutdown()

void ttv::PubSubTopicListenerHelper::Shutdown ( )

◆ Subscribe()

TTV_ErrorCode ttv::PubSubTopicListenerHelper::Subscribe ( const std::string &  topic)

◆ Unsubscribe()

TTV_ErrorCode ttv::PubSubTopicListenerHelper::Unsubscribe ( const std::string &  topic)

Member Data Documentation

◆ mListener

std::weak_ptr<PubSubClient::ITopicListener> ttv::PubSubTopicListenerHelper::mListener
protected

◆ mPubSub

std::shared_ptr<PubSubClient> ttv::PubSubTopicListenerHelper::mPubSub
protected

◆ mState

State ttv::PubSubTopicListenerHelper::mState
protected

◆ mSubscriptionStates

std::map<std::string, Entry> ttv::PubSubTopicListenerHelper::mSubscriptionStates
protected

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