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

#include <channelstatus.h>

Inheritance diagram for ttv::ChannelStatus:
ttv::PubSubComponent< IChannelListener > ttv::IChannelStatus ttv::PubSubComponentBase ttv::UserComponent ttv::Component ttv::IComponent

Public Types

using DisposerFunc = std::function< void()>
 
enum  State { State::Uninitialized, State::Initialized, State::ShuttingDown, State::Inert }
 
using UploadProfileImageCallback = std::function< void(TTV_ErrorCode ec, const std::vector< ProfileImage > &images)>
 

Public Member Functions

 ChannelStatus (const std::shared_ptr< User > &user, ChannelId channelId)
 
virtual TTV_ErrorCode Dispose () override
 
virtual TTV_ErrorCode UploadProfileImage (const char *imageBuffer, size_t imageSize, const UploadProfileImageCallback &callback) override
 
virtual TTV_ErrorCode Initialize () override
 
virtual void Update () override
 
virtual std::string GetLoggerName () const 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< IChannelListener > &listener)
 
void SetDisposer (DisposerFunc &&func)
 
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 CompleteShutdown () 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< IChannelListenermListener
 
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::shared_ptr< ComponentContainermComponentContainer
 
std::string mPubSubTopic
 
ChannelId mChannelId
 

Detailed Description

A concrete implemenation of IChannelStatus.

Member Typedef Documentation

◆ DisposerFunc

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

◆ UploadProfileImageCallback

using ttv::IChannelStatus::UploadProfileImageCallback = std::function<void(TTV_ErrorCode ec, const std::vector<ProfileImage>& images)>
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

◆ ChannelStatus()

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

Member Function Documentation

◆ AddTopic()

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

◆ CheckShutdown()

virtual bool ttv::ChannelStatus::CheckShutdown ( )
overrideprotectedvirtual

Reimplemented from ttv::PubSubComponentBase.

◆ CompleteShutdown()

virtual void ttv::ChannelStatus::CompleteShutdown ( )
overrideprotectedvirtual

◆ CompleteTask()

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

◆ Dispose()

virtual TTV_ErrorCode ttv::ChannelStatus::Dispose ( )
overridevirtual

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

Implements ttv::IChannelStatus.

◆ GetComponentName()

static std::string ttv::ChannelStatus::GetComponentName ( )
inlinestatic

◆ GetLoggerName()

virtual std::string ttv::ChannelStatus::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::ChannelStatus::Initialize ( )
overridevirtual

Reimplemented from ttv::PubSubComponentBase.

◆ IsTaskRunning()

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

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

◆ OnTopicSubscribeStateChanged()

void ttv::ChannelStatus::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< IChannelListener >::SetListener ( const std::shared_ptr< IChannelListener > &  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::ChannelStatus::Update ( )
overridevirtual

Reimplemented from ttv::Component.

◆ UploadProfileImage()

virtual TTV_ErrorCode ttv::ChannelStatus::UploadProfileImage ( const char *  imageBuffer,
size_t  imageSize,
const UploadProfileImageCallback callback 
)
overridevirtual

Uploads a new profile image for the current user asynchronously. Only one request can be in progress at a time. This function will call HttpRequest::SendHttpRequest: the client implementation of this must be able to send raw bytes (and not apply any encoding such as UTF-16).

Parameters
[in]imageBufferA buffer containing the image data to be uploaded.
[in]sizeThe size of the image to be uploaded (in bytes).
[in]callbackThe callback to be called upon completion of the upload (whether successful or not) The callback has several error codes that it can return:
  • TTV_EC_SUCCESS: We have successfully uploaded and updated the profile image.
  • TTV_EC_API_REQUEST_FAILED: The API requests to upload the profile image have failed.
  • TTV_EC_PROFILEIMAGE_IMAGE_VALIDATION_FAILED: The profile image was uploaded, but is not a valid image.
  • TTV_EC_PROFILEIMAGE_FORMAT_VALIDATION_FAILED: The profile image was uploaded, but is not in a valid image format.
  • TTV_EC_PROFILEIMAGE_SIZE_VALIDATION_FAILED: The profile image was uploaded, but it is too big to be used (over 5 MB). The callback will also return a vector of the profile image in different dimensions if the upload was successful.
  • Each ProfileImage object in the vector contains the dimensions, url, and image format.
Returns
  • TTV_EC_SUCCESS: We've initialized and started the profile image upload successfully.
  • TTV_EC_NOT_INITIALIZED: We haven't initialized properly.
  • TTV_EC_NEED_TO_LOGIN: We aren't logged in properly.
  • TTV_EC_INVALID_ARG: If any input arguments are invalid.
  • TTV_EC_REQUEST_PENDING: If a request is already pending.
  • TTV_EC_API_REQUEST_FAILED: The API requests to upload the profile image have failed.

Implements ttv::IChannelStatus.

Member Data Documentation

◆ mChannelId

ChannelId ttv::ChannelStatus::mChannelId
private

◆ mComponentContainer

std::shared_ptr<ComponentContainer> ttv::ChannelStatus::mComponentContainer
private

◆ mDisposerFunc

DisposerFunc ttv::PubSubComponentBase::mDisposerFunc
protectedinherited

◆ mListener

std::shared_ptr<IChannelListener > ttv::PubSubComponent< IChannelListener >::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::ChannelStatus::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

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