Twitch SDK (Internal)
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ttv::chat::ChannelChatRoomManager Class Reference

#include <channelchatroommanager.h>

Inheritance diagram for ttv::chat::ChannelChatRoomManager:
ttv::chat::IChannelChatRoomManager ttv::PubSubComponent< IChannelChatRoomManagerListener > ttv::PubSubComponentBase ttv::UserComponent ttv::Component ttv::IComponent

Public Types

using DisposerFunc = std::function< void()>
 
using JoinCallback = std::function< void(TTV_ErrorCode ec)>
 
using LeaveCallback = std::function< void(TTV_ErrorCode ec)>
 
using AddRoomCallback = std::function< void(TTV_ErrorCode ec, CreateRoomError &&error, ChatRoomInfo &&info)>
 
using FetchRoomsInfoCallback = std::function< void(TTV_ErrorCode ec, std::vector< ChatRoomInfo > &&infos)>
 
enum  State { State::Uninitialized, State::Initialized, State::ShuttingDown, State::Inert }
 

Public Member Functions

 ChannelChatRoomManager (const std::shared_ptr< User > &user, ChannelId channelId)
 
virtual std::string GetLoggerName () const override
 
virtual TTV_ErrorCode Dispose () override
 
virtual TTV_ErrorCode AddNewChatRoom (const std::string &roomName, const std::string &topic, bool isPreviewable, RoomRole minimumAllowedRole, const AddRoomCallback &callback) override
 
virtual TTV_ErrorCode JoinChatRooms (const JoinCallback &callback) override
 
virtual TTV_ErrorCode LeaveChatRooms (const LeaveCallback &callback) override
 
virtual TTV_ErrorCode FetchChatRoomsInfo (const FetchRoomsInfoCallback &callback) override
 
void OnTopicSubscribeStateChanged (const std::string &topic, PubSubClient::SubscribeState::Enum state, TTV_ErrorCode ec) override
 
void OnTopicMessageReceived (const std::string &topic, const ttv::json::Value &jVal) override
 
virtual void CompleteShutdown () override
 
void SetListener (const std::shared_ptr< IChannelChatRoomManagerListener > &listener)
 
void SetDisposer (DisposerFunc &&func)
 
virtual TTV_ErrorCode Initialize () override
 
virtual TTV_ErrorCode Shutdown () override
 
virtual void OnTopicListenerRemoved (const std::string &topic, TTV_ErrorCode ec)
 
virtual void SetTaskRunner (std::shared_ptr< TaskRunner > taskRunner)
 
std::shared_ptr< TaskRunnerGetTaskRunner ()
 
virtual State GetState () const override
 
virtual void Update () override
 

Static Public Member Functions

static std::string GetComponentName ()
 

Protected Member Functions

virtual bool CheckShutdown () override
 
virtual void AddTopic (const std::string &topic)
 
virtual TTV_ErrorCode SubscribeTopics ()
 
virtual void OnUserLogInComplete (TTV_ErrorCode ec)
 
virtual void OnUserLogOutComplete (TTV_ErrorCode ec)
 
virtual void OnUserInfoFetchComplete (TTV_ErrorCode ec)
 
virtual void OnUserAuthenticationIssue (std::shared_ptr< const OAuthToken > oauthToken, TTV_ErrorCode ec)
 
void Log (TTV_MessageLevel level, const char *format,...)
 
TTV_ErrorCode StartTask (std::shared_ptr< Task > task)
 
void CompleteTask (Task *task)
 
bool IsTaskRunning (Task *task) const
 
virtual void SetState (State state)
 
virtual void SetClientState (State state)
 
virtual void SetServerState (State state)
 

Protected Attributes

std::shared_ptr< IChannelChatRoomManagerListenermListener
 
std::shared_ptr< PubSubClientmPubSub
 
std::shared_ptr< PubSubTopicListenermPubSubTopicListener
 
std::shared_ptr< PubSubTopicListenerHelpermPubSubTopicListenerHelper
 
DisposerFunc mDisposerFunc
 
std::vector< std::string > mPubSubTopics
 
std::weak_ptr< UsermUser
 
bool mOAuthIssue
 Whether or not the internal updates of the component are on hold because of an issue with the OAuth token. More...
 
ClientServerValue< StatemState
 
std::shared_ptr< TaskRunnermTaskRunner
 
std::vector< std::shared_ptr< Task > > mRunningTasks
 
std::mutex mTaskMutex
 
uint64_t mShutdownTimeMilliseconds
 

Private Attributes

std::string mPubSubTopic
 
UserId mUserId
 
ChannelId mChannelId
 

Member Typedef Documentation

◆ AddRoomCallback

using ttv::chat::IChannelChatRoomManager::AddRoomCallback = std::function<void(TTV_ErrorCode ec, CreateRoomError&& error, ChatRoomInfo&& info)>
inherited

Used with AddNewChatRoom().

Parameters
[in]ec
  • TTV_EC_SUCCESS: The channel has created a new chat room.
  • TTV_EC_WEBAPI_RESULT_INVALID_JSON: Something went wrong when trying to create a new chat room.
  • TTV_EC_GRAPHQL_ERROR: Received an error code from the back-end.
[in]errorError object describing the reason why creating the room failed.
[in]infoThe information of the newly created room.

◆ DisposerFunc

using ttv::chat::ChannelChatRoomManager::DisposerFunc = std::function<void()>

◆ FetchRoomsInfoCallback

using ttv::chat::IChannelChatRoomManager::FetchRoomsInfoCallback = std::function<void(TTV_ErrorCode ec, std::vector<ChatRoomInfo>&& infos)>
inherited

Used with FetchRoomsInfo().

Parameters
[in]ec
  • TTV_EC_SUCCESS: The channel has created a new chat room.
  • TTV_EC_WEBAPI_RESULT_INVALID_JSON: Something went wrong when trying to create a new chat room.
[in]infosA list of the information for chat rooms on the channel.

◆ JoinCallback

using ttv::chat::IChannelChatRoomManager::JoinCallback = std::function<void(TTV_ErrorCode ec)>
inherited

Used with JoinChatRooms().

Parameters
[in]ec
  • TTV_EC_SUCCESS: The rooms was successfully joined.
  • TTV_EC_WEBAPI_RESULT_INVALID_JSON: Something went wrong when trying to join the rooms.

◆ LeaveCallback

using ttv::chat::IChannelChatRoomManager::LeaveCallback = std::function<void(TTV_ErrorCode ec)>
inherited

Used with LeaveChatRooms().

Parameters
[in]ec
  • TTV_EC_SUCCESS: The rooms was successfully left.
  • TTV_EC_WEBAPI_RESULT_INVALID_JSON: Something went wrong when trying to leave the rooms.

Member Enumeration Documentation

◆ State

enum ttv::IComponent::State
stronginherited
Enumerator
Uninitialized 
Initialized 
ShuttingDown 
Inert 

The component doesn't require shutting down.

Constructor & Destructor Documentation

◆ ChannelChatRoomManager()

ttv::chat::ChannelChatRoomManager::ChannelChatRoomManager ( const std::shared_ptr< User > &  user,
ChannelId  channelId 
)

Member Function Documentation

◆ AddNewChatRoom()

virtual TTV_ErrorCode ttv::chat::ChannelChatRoomManager::AddNewChatRoom ( const std::string &  roomName,
const std::string &  topic,
bool  isPreviewable,
RoomRole  minimumAllowedRole,
const AddRoomCallback callback 
)
overridevirtual

Adds a new chat room for the channel. Currently to create a new room, the user must own the channel (userId and channelId must be the same).

Parameters
[in]roomNameThe name of the newly created room.
[in]topicThe topic of the newly created room.
[in]isPreviewableWhether the newly created room will be previewable.
[in]minimumAllowedRoleThe minimum required role for a user to join the room.
[in]callbackCallback when API call returns, receives an error code and the newly created room's information.
Returns
  • TTV_EC_SUCCESS: We've sent the request to add a new chat room.
  • TTV_EC_SHUT_DOWN: The chat room object is not initialized.
  • TTV_EC_NEED_TO_LOGIN: The user is not properly logged in.
  • TTV_EC_INVALID_CHANNEL_ID: ChannelChatRoomManager's user id does not match channel id (currently the user must own the channel to add a new room)

Implements ttv::chat::IChannelChatRoomManager.

◆ AddTopic()

virtual void ttv::PubSubComponentBase::AddTopic ( const std::string &  topic)
protectedvirtualinherited

◆ CheckShutdown()

virtual bool ttv::PubSubComponentBase::CheckShutdown ( )
overrideprotectedvirtualinherited

Reimplemented from ttv::Component.

Reimplemented in ttv::ChannelStatus, and ttv::ProfileImageStatus.

◆ CompleteShutdown()

virtual void ttv::PubSubComponent< IChannelChatRoomManagerListener >::CompleteShutdown ( )
inlineoverridevirtualinherited

Reimplemented from ttv::PubSubComponentBase.

◆ CompleteTask()

void ttv::Component::CompleteTask ( Task task)
protectedinherited

◆ Dispose()

virtual TTV_ErrorCode ttv::chat::ChannelChatRoomManager::Dispose ( )
overridevirtual

This should be called when the application is done with the instance.

Returns
  • TTV_EC_SUCCESS: Instance has been disposed.

Implements ttv::chat::IChannelChatRoomManager.

◆ FetchChatRoomsInfo()

virtual TTV_ErrorCode ttv::chat::ChannelChatRoomManager::FetchChatRoomsInfo ( const FetchRoomsInfoCallback callback)
overridevirtual

Return all of the information for chat rooms on this channel.

Parameters
[in]callbackCallback when the API call returns, receives an error code and a list of information for the chat rooms of the channel.
Returns
  • TTV_EC_SUCCESS: We've sent the request to fetch the chat rooms information.
  • TTV_EC_SHUT_DOWN: The chat room object is not initialized.
  • TTV_EC_NEED_TO_LOGIN: The user is not properly logged in.

Implements ttv::chat::IChannelChatRoomManager.

◆ GetComponentName()

static std::string ttv::chat::ChannelChatRoomManager::GetComponentName ( )
inlinestatic

◆ GetLoggerName()

virtual std::string ttv::chat::ChannelChatRoomManager::GetLoggerName ( ) const
overridevirtual

◆ GetState()

virtual State ttv::Component::GetState ( ) const
overridevirtualinherited

Implements ttv::IComponent.

◆ GetTaskRunner()

std::shared_ptr<TaskRunner> ttv::Component::GetTaskRunner ( )
inlineinherited

◆ Initialize()

virtual TTV_ErrorCode ttv::PubSubComponentBase::Initialize ( )
overridevirtualinherited

◆ IsTaskRunning()

bool ttv::Component::IsTaskRunning ( Task task) const
protectedinherited

◆ JoinChatRooms()

virtual TTV_ErrorCode ttv::chat::ChannelChatRoomManager::JoinChatRooms ( const JoinCallback callback)
overridevirtual

Join the chat rooms for a channel.

Parameters
[in]callbackCallback when the API call returns, receives an error code.
Returns
  • TTV_EC_SUCCESS: We've sent the request to join the channel.
  • TTV_EC_SHUT_DOWN: The chat room object is not initialized.
  • TTV_EC_NEED_TO_LOGIN: The user is not properly logged in.

Implements ttv::chat::IChannelChatRoomManager.

◆ LeaveChatRooms()

virtual TTV_ErrorCode ttv::chat::ChannelChatRoomManager::LeaveChatRooms ( const LeaveCallback callback)
overridevirtual

Leave the chat rooms for a channel.

Parameters
[in]callbackCallback when the API call returns, receives an error code.
Returns
  • TTV_EC_SUCCESS: We've sent the request to leave the channel.
  • TTV_EC_SHUT_DOWN: The chat room object is not initialized.
  • TTV_EC_NEED_TO_LOGIN: The user is not properly logged in.

Implements ttv::chat::IChannelChatRoomManager.

◆ Log()

void ttv::UserComponent::Log ( TTV_MessageLevel  level,
const char *  format,
  ... 
)
protectedinherited

◆ OnTopicListenerRemoved()

virtual void ttv::PubSubComponentBase::OnTopicListenerRemoved ( const std::string &  topic,
TTV_ErrorCode  ec 
)
virtualinherited

◆ OnTopicMessageReceived()

void ttv::chat::ChannelChatRoomManager::OnTopicMessageReceived ( const std::string &  topic,
const ttv::json::Value jVal 
)
overridevirtual

◆ OnTopicSubscribeStateChanged()

void ttv::chat::ChannelChatRoomManager::OnTopicSubscribeStateChanged ( const std::string &  topic,
PubSubClient::SubscribeState::Enum  state,
TTV_ErrorCode  ec 
)
overridevirtual

◆ OnUserAuthenticationIssue()

virtual void ttv::UserComponent::OnUserAuthenticationIssue ( std::shared_ptr< const OAuthToken oauthToken,
TTV_ErrorCode  ec 
)
protectedvirtualinherited

◆ OnUserInfoFetchComplete()

virtual void ttv::UserComponent::OnUserInfoFetchComplete ( TTV_ErrorCode  ec)
protectedvirtualinherited

◆ OnUserLogInComplete()

virtual void ttv::UserComponent::OnUserLogInComplete ( TTV_ErrorCode  ec)
protectedvirtualinherited

◆ OnUserLogOutComplete()

virtual void ttv::UserComponent::OnUserLogOutComplete ( TTV_ErrorCode  ec)
protectedvirtualinherited

◆ SetClientState()

virtual void ttv::Component::SetClientState ( State  state)
protectedvirtualinherited

◆ SetDisposer()

void ttv::PubSubComponentBase::SetDisposer ( DisposerFunc &&  func)
inlineinherited

◆ SetListener()

void ttv::PubSubComponent< IChannelChatRoomManagerListener >::SetListener ( const std::shared_ptr< IChannelChatRoomManagerListener > &  listener)
inlineinherited

◆ SetServerState()

virtual void ttv::Component::SetServerState ( State  state)
protectedvirtualinherited

◆ SetState()

virtual void ttv::Component::SetState ( State  state)
protectedvirtualinherited

◆ SetTaskRunner()

virtual void ttv::Component::SetTaskRunner ( std::shared_ptr< TaskRunner taskRunner)
virtualinherited

◆ Shutdown()

virtual TTV_ErrorCode ttv::PubSubComponentBase::Shutdown ( )
overridevirtualinherited

Reimplemented from ttv::Component.

Reimplemented in ttv::chat::BitsStatus, and ttv::chat::UserEmoticonSets.

◆ StartTask()

TTV_ErrorCode ttv::Component::StartTask ( std::shared_ptr< Task task)
protectedinherited

◆ SubscribeTopics()

virtual TTV_ErrorCode ttv::PubSubComponentBase::SubscribeTopics ( )
protectedvirtualinherited

◆ Update()

virtual void ttv::Component::Update ( )
overridevirtualinherited

Member Data Documentation

◆ mChannelId

ChannelId ttv::chat::ChannelChatRoomManager::mChannelId
private

◆ mDisposerFunc

DisposerFunc ttv::PubSubComponentBase::mDisposerFunc
protectedinherited

◆ mListener

std::shared_ptr<IChannelChatRoomManagerListener > ttv::PubSubComponent< IChannelChatRoomManagerListener >::mListener
protectedinherited

◆ mOAuthIssue

bool ttv::UserComponent::mOAuthIssue
protectedinherited

Whether or not the internal updates of the component are on hold because of an issue with the OAuth token.

◆ mPubSub

std::shared_ptr<PubSubClient> ttv::PubSubComponentBase::mPubSub
protectedinherited

◆ mPubSubTopic

std::string ttv::chat::ChannelChatRoomManager::mPubSubTopic
private

◆ mPubSubTopicListener

std::shared_ptr<PubSubTopicListener> ttv::PubSubComponentBase::mPubSubTopicListener
protectedinherited

◆ mPubSubTopicListenerHelper

std::shared_ptr<PubSubTopicListenerHelper> ttv::PubSubComponentBase::mPubSubTopicListenerHelper
protectedinherited

◆ mPubSubTopics

std::vector<std::string> ttv::PubSubComponentBase::mPubSubTopics
protectedinherited

◆ mRunningTasks

std::vector<std::shared_ptr<Task> > ttv::Component::mRunningTasks
protectedinherited

◆ mShutdownTimeMilliseconds

uint64_t ttv::Component::mShutdownTimeMilliseconds
protectedinherited

◆ mState

ClientServerValue<State> ttv::Component::mState
protectedinherited

◆ mTaskMutex

std::mutex ttv::Component::mTaskMutex
mutableprotectedinherited

◆ mTaskRunner

std::shared_ptr<TaskRunner> ttv::Component::mTaskRunner
protectedinherited

◆ mUser

std::weak_ptr<User> ttv::UserComponent::mUser
protectedinherited

◆ mUserId

UserId ttv::chat::ChannelChatRoomManager::mUserId
private

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