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

#include <chatapitaskhost.h>

Inheritance diagram for ttv::chat::ChatAPITaskHost:
ttv::Component ttv::IComponent

Public Types

using BanUserCallback = std::function< void(TTV_ErrorCode ec, BanUserError &&error)>
 
using UnbanUserCallback = std::function< void(TTV_ErrorCode ec, UnbanUserError &&error)>
 
using ModUserCallback = std::function< void(TTV_ErrorCode ec, ModUserError &&error)>
 
using UnmodUserCallback = std::function< void(TTV_ErrorCode ec, UnmodUserError &&error)>
 
using UpdateUserColorCallback = std::function< void(TTV_ErrorCode ec)>
 
using FetchChannelModeratorsCallback = std::function< void(TTV_ErrorCode ec, std::vector< std::string > &&modNames, std::string &&nextCursor)>
 
using FetchBadgesCallback = std::function< void(TTV_ErrorCode ec, BadgeSet &&result)>
 
enum  State { State::Uninitialized, State::Initialized, State::ShuttingDown, State::Inert }
 

Public Member Functions

 ChatAPITaskHost ()
 
TTV_ErrorCode BanUser (UserId userId, ChannelId channelId, const std::string &bannedUserName, uint32_t duration, BanUserCallback &&callback)
 
TTV_ErrorCode UnbanUser (UserId userId, ChannelId channelId, const std::string &unbannedUserName, UnbanUserCallback &&callback)
 
TTV_ErrorCode ModUser (UserId userId, ChannelId channelId, const std::string &modUserName, ModUserCallback &&callback)
 
TTV_ErrorCode UnmodUser (UserId userId, ChannelId channelId, const std::string &unmodUserName, UnmodUserCallback &&callback)
 
TTV_ErrorCode UpdateUserColor (UserId userId, const std::string &color, UpdateUserColorCallback &&callback)
 
TTV_ErrorCode FetchChannelModerators (ChannelId channelId, const std::string &cursor, FetchChannelModeratorsCallback &&callback)
 
TTV_ErrorCode FetchGlobalBadges (const std::string &language, FetchBadgesCallback &&callback)
 
TTV_ErrorCode FetchChannelBadges (ChannelId channelId, const std::string &language, FetchBadgesCallback &&callback)
 
void SetUserRepository (const std::shared_ptr< UserRepository > &repository)
 
virtual std::string GetLoggerName () const override
 
virtual void SetTaskRunner (std::shared_ptr< TaskRunner > taskRunner)
 
std::shared_ptr< TaskRunnerGetTaskRunner ()
 
virtual State GetState () const override
 
virtual TTV_ErrorCode Initialize () override
 
virtual void Update () override
 
virtual TTV_ErrorCode Shutdown () override
 

Protected Member Functions

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)
 
virtual bool CheckShutdown ()
 
virtual void CompleteShutdown ()
 

Protected Attributes

ClientServerValue< StatemState
 
std::shared_ptr< TaskRunnermTaskRunner
 
std::vector< std::shared_ptr< Task > > mRunningTasks
 
std::mutex mTaskMutex
 
uint64_t mShutdownTimeMilliseconds
 

Private Attributes

std::shared_ptr< UserRepositorymUserRepository
 

Detailed Description

This class is used to call API endpoints for ChatAPI functions. A separate component is necessary to ensure we have properly finished running tasks when ChatAPI shuts down.

Member Typedef Documentation

◆ BanUserCallback

◆ FetchBadgesCallback

using ttv::chat::ChatAPITaskHost::FetchBadgesCallback = std::function<void(TTV_ErrorCode ec, BadgeSet&& result)>

◆ FetchChannelModeratorsCallback

using ttv::chat::ChatAPITaskHost::FetchChannelModeratorsCallback = std::function<void(TTV_ErrorCode ec, std::vector<std::string>&& modNames, std::string&& nextCursor)>

◆ ModUserCallback

◆ UnbanUserCallback

◆ UnmodUserCallback

◆ UpdateUserColorCallback

Member Enumeration Documentation

◆ State

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

The component doesn't require shutting down.

Constructor & Destructor Documentation

◆ ChatAPITaskHost()

ttv::chat::ChatAPITaskHost::ChatAPITaskHost ( )

Member Function Documentation

◆ BanUser()

TTV_ErrorCode ttv::chat::ChatAPITaskHost::BanUser ( UserId  userId,
ChannelId  channelId,
const std::string &  bannedUserName,
uint32_t  duration,
BanUserCallback &&  callback 
)

◆ CheckShutdown()

virtual bool ttv::Component::CheckShutdown ( )
protectedvirtualinherited

◆ CompleteShutdown()

virtual void ttv::Component::CompleteShutdown ( )
protectedvirtualinherited

◆ CompleteTask()

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

◆ FetchChannelBadges()

TTV_ErrorCode ttv::chat::ChatAPITaskHost::FetchChannelBadges ( ChannelId  channelId,
const std::string &  language,
FetchBadgesCallback &&  callback 
)

◆ FetchChannelModerators()

TTV_ErrorCode ttv::chat::ChatAPITaskHost::FetchChannelModerators ( ChannelId  channelId,
const std::string &  cursor,
FetchChannelModeratorsCallback &&  callback 
)

◆ FetchGlobalBadges()

TTV_ErrorCode ttv::chat::ChatAPITaskHost::FetchGlobalBadges ( const std::string &  language,
FetchBadgesCallback &&  callback 
)

◆ GetLoggerName()

virtual std::string ttv::chat::ChatAPITaskHost::GetLoggerName ( ) const
inlineoverridevirtual

Implements ttv::Component.

◆ 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::Component::Initialize ( )
overridevirtualinherited

◆ IsTaskRunning()

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

◆ ModUser()

TTV_ErrorCode ttv::chat::ChatAPITaskHost::ModUser ( UserId  userId,
ChannelId  channelId,
const std::string &  modUserName,
ModUserCallback &&  callback 
)

◆ SetClientState()

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

◆ 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

◆ SetUserRepository()

void ttv::chat::ChatAPITaskHost::SetUserRepository ( const std::shared_ptr< UserRepository > &  repository)
inline

◆ Shutdown()

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

◆ StartTask()

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

◆ UnbanUser()

TTV_ErrorCode ttv::chat::ChatAPITaskHost::UnbanUser ( UserId  userId,
ChannelId  channelId,
const std::string &  unbannedUserName,
UnbanUserCallback &&  callback 
)

◆ UnmodUser()

TTV_ErrorCode ttv::chat::ChatAPITaskHost::UnmodUser ( UserId  userId,
ChannelId  channelId,
const std::string &  unmodUserName,
UnmodUserCallback &&  callback 
)

◆ Update()

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

◆ UpdateUserColor()

TTV_ErrorCode ttv::chat::ChatAPITaskHost::UpdateUserColor ( UserId  userId,
const std::string &  color,
UpdateUserColorCallback &&  callback 
)

Member Data Documentation

◆ 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

◆ mUserRepository

std::shared_ptr<UserRepository> ttv::chat::ChatAPITaskHost::mUserRepository
private

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