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

#include <chatraid.h>

Inheritance diagram for ttv::chat::ChatRaid:
ttv::PubSubComponent< IChatRaidListener > ttv::chat::IChatRaid ttv::PubSubComponentBase ttv::UserComponent ttv::Component ttv::IComponent

Classes

struct  RaidEntry
 

Public Types

using DisposerFunc = std::function< void()>
 
enum  State { State::Uninitialized, State::Initialized, State::ShuttingDown, State::Inert }
 
using JoinCallback = std::function< void(TTV_ErrorCode ec)>
 
using LeaveCallback = std::function< void(TTV_ErrorCode ec)>
 
using StartCallback = std::function< void(TTV_ErrorCode ec)>
 
using CancelCallback = std::function< void(TTV_ErrorCode ec)>
 

Public Member Functions

 ChatRaid (const std::shared_ptr< User > &user, ChannelId sourceChannelId)
 
virtual void Update () override
 
virtual std::string GetLoggerName () const override
 
virtual TTV_ErrorCode Dispose () override
 
virtual TTV_ErrorCode Join (const std::string &raidId, const JoinCallback &callback) override
 
virtual TTV_ErrorCode Leave (const std::string &raidId, const LeaveCallback &callback) override
 
virtual TTV_ErrorCode Start (UserId targetUserId, const StartCallback &callback) override
 
virtual TTV_ErrorCode Cancel (const CancelCallback &callback) override
 
void OnTopicSubscribeStateChanged (const std::string &topic, PubSubClient::SubscribeState::Enum state, TTV_ErrorCode ec) override
 
void OnTopicMessageReceived (const std::string &topic, const json::Value &msg) override
 
void SetListener (const std::shared_ptr< IChatRaidListener > &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
 

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< IChatRaidListenermListener
 
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 Member Functions

virtual void CompleteShutdown () override
 
void HandleRaidStatus (RaidStatus &status, bool isCancel)
 

Private Attributes

std::map< std::string, RaidEntrymRaids
 
std::string mPubSubTopic
 
ChannelId mSourceChannelId
 

Detailed Description

A concrete implemenation of IChatRaid.

Member Typedef Documentation

◆ CancelCallback

using ttv::chat::IChatRaid::CancelCallback = std::function<void(TTV_ErrorCode ec)>
inherited

◆ DisposerFunc

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

◆ JoinCallback

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

◆ LeaveCallback

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

◆ StartCallback

using ttv::chat::IChatRaid::StartCallback = std::function<void(TTV_ErrorCode ec)>
inherited

Member Enumeration Documentation

◆ State

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

The component doesn't require shutting down.

Constructor & Destructor Documentation

◆ ChatRaid()

ttv::chat::ChatRaid::ChatRaid ( const std::shared_ptr< User > &  user,
ChannelId  sourceChannelId 
)

Member Function Documentation

◆ AddTopic()

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

◆ Cancel()

virtual TTV_ErrorCode ttv::chat::ChatRaid::Cancel ( const CancelCallback callback)
overridevirtual

As a channel moderator or broadcaster, this cancels a raid. This only works if a raid has been started and is currently underway.

Parameters
[in]targetUserIdThe id of the user that is being targetted by the raid.
[in]callbackCallback function called after cancelling the raid. Can be null.
Returns
  • TTV_EC_SUCCESS: The raid was cancelled successfully.
  • TTV_EC_SHUT_DOWN: The chat module is not initialized.
  • TTV_EC_NEED_TO_LOGIN: User needs to be logged in to leave the raid.
  • TTV_EC_AUTHENTICATION: User has an invalid OAuth token.

Implements ttv::chat::IChatRaid.

◆ CheckShutdown()

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

Reimplemented from ttv::Component.

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

◆ CompleteShutdown()

virtual void ttv::chat::ChatRaid::CompleteShutdown ( )
overrideprivatevirtual

◆ CompleteTask()

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

◆ Dispose()

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

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

Implements ttv::chat::IChatRaid.

◆ GetComponentName()

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

◆ GetLoggerName()

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

◆ GetState()

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

Implements ttv::IComponent.

◆ GetTaskRunner()

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

◆ HandleRaidStatus()

void ttv::chat::ChatRaid::HandleRaidStatus ( RaidStatus status,
bool  isCancel 
)
private

◆ Initialize()

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

◆ IsTaskRunning()

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

◆ Join()

virtual TTV_ErrorCode ttv::chat::ChatRaid::Join ( const std::string &  raidId,
const JoinCallback callback 
)
overridevirtual

As a viewer, joins the raid.

Parameters
[in]raidIdThe id of the raid that is being joined.
[in]callbackCallback function called after joining the raid. Can be null.
Returns
  • TTV_EC_SUCCESS: The raid was joined successfully.
  • TTV_EC_SHUT_DOWN: The chat module is not initialized.
  • TTV_EC_NEED_TO_LOGIN: User needs to be logged in to participate in raid.
  • TTV_EC_AUTHENTICATION: User has an invalid OAuth token.

Implements ttv::chat::IChatRaid.

◆ Leave()

virtual TTV_ErrorCode ttv::chat::ChatRaid::Leave ( const std::string &  raidId,
const LeaveCallback callback 
)
overridevirtual

As a viewer, leaves the raid. You can only leave a raid if you have previously joined.

Parameters
[in]raidIdThe id of the raid that is being left.
[in]callbackCallback function called after leaving the raid. Can be null.
Returns
  • TTV_EC_SUCCESS: The raid was left successfully.
  • TTV_EC_SHUT_DOWN: The chat module is not initialized.
  • TTV_EC_NEED_TO_LOGIN: User needs to be logged in to participate in raid.
  • TTV_EC_AUTHENTICATION: User has an invalid OAuth token.

Implements ttv::chat::IChatRaid.

◆ 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::ChatRaid::OnTopicMessageReceived ( const std::string &  topic,
const json::Value msg 
)
overridevirtual

◆ OnTopicSubscribeStateChanged()

void ttv::chat::ChatRaid::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< IChatRaidListener >::SetListener ( const std::shared_ptr< IChatRaidListener > &  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.

◆ Start()

virtual TTV_ErrorCode ttv::chat::ChatRaid::Start ( UserId  targetUserId,
const StartCallback callback 
)
overridevirtual

As a channel moderator or broadcaster, this starts a raid on the channel targeting the given user.

Parameters
[in]targetUserIdThe id of the user that is being targetted by the raid.
[in]callbackCallback function called after starting the raid. Can be null.
Returns
  • TTV_EC_SUCCESS: The raid was started successfully.
  • TTV_EC_SHUT_DOWN: The chat module is not initialized.
  • TTV_EC_NEED_TO_LOGIN: User needs to be logged in to start a raid.
  • TTV_EC_AUTHENTICATION: User has an invalid OAuth token.

Implements ttv::chat::IChatRaid.

◆ StartTask()

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

◆ SubscribeTopics()

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

◆ Update()

virtual void ttv::chat::ChatRaid::Update ( )
overridevirtual

Reimplemented from ttv::Component.

Member Data Documentation

◆ mDisposerFunc

DisposerFunc ttv::PubSubComponentBase::mDisposerFunc
protectedinherited

◆ mListener

std::shared_ptr<IChatRaidListener > ttv::PubSubComponent< IChatRaidListener >::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::ChatRaid::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

◆ mRaids

std::map<std::string, RaidEntry> ttv::chat::ChatRaid::mRaids
private

◆ mRunningTasks

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

◆ mShutdownTimeMilliseconds

uint64_t ttv::Component::mShutdownTimeMilliseconds
protectedinherited

◆ mSourceChannelId

ChannelId ttv::chat::ChatRaid::mSourceChannelId
private

◆ 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

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