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

#include <chatreplay.h>

Inheritance diagram for ttv::chat::ChatReplay:
ttv::Component ttv::chat::IChatReplay ttv::IComponent

Classes

struct  ReplayMessageBatch
 

Public Types

using DisposerFunc = std::function< void()>
 
enum  State { State::Uninitialized, State::Initialized, State::ShuttingDown, State::Inert }
 

Public Member Functions

 ChatReplay (const std::shared_ptr< User > &user)
 
void SetDisposer (DisposerFunc &&func)
 
void SetVodId (const std::string &vodId)
 
void SetTokenizationOptions (const TokenizationOptions &tokenizationOptions)
 
void AddListener (const std::shared_ptr< IChatReplayListener > &listener)
 
void SetChannelRepository (const std::shared_ptr< ChannelRepository > &repository)
 
void SetBitsConfigRepository (const std::shared_ptr< BitsConfigRepository > &repository)
 
std::string GetVodId () const
 
virtual TTV_ErrorCode Initialize () override
 
virtual void Update () override
 
virtual TTV_ErrorCode Shutdown () override
 
virtual void CompleteShutdown () override
 
virtual std::string GetLoggerName () const override
 
virtual TTV_ErrorCode Dispose () override
 
virtual TTV_ErrorCode Play () override
 
virtual TTV_ErrorCode Pause () override
 
virtual TTV_ErrorCode Seek (Timestamp timestamp) override
 
virtual TTV_ErrorCode NudgePlayhead (uint64_t timestampMilliseconds) override
 
virtual TTV_ErrorCode GetCurrentTime (Timestamp &timestamp) const override
 
virtual TTV_ErrorCode DeleteMessage (const std::string &messageId) override
 
virtual TTV_ErrorCode GetChannelId (UserId &result) const override
 
virtual TTV_ErrorCode GetReplayState (ChatReplayState &result) const override
 
virtual void SetTaskRunner (std::shared_ptr< TaskRunner > taskRunner)
 
std::shared_ptr< TaskRunnerGetTaskRunner ()
 
virtual State GetState () const 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 ()
 

Protected Attributes

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

Private Member Functions

TTV_ErrorCode FetchVod ()
 
TTV_ErrorCode FetchBitsConfig ()
 
TTV_ErrorCode FetchChatReplayMessagesAtMillisecond (uint64_t timestamp)
 
void Advance ()
 
void SetReplayState (ChatReplayState state)
 

Private Attributes

std::string mVodId
 
std::shared_ptr< UsermUser
 
EventSource< IChatReplayListenermListeners
 
std::vector< ReplayMessageBatchmFetchedLists
 
std::shared_ptr< ChannelRepositorymChannelRepository
 
std::shared_ptr< BitsConfigRepositorymBitsConfigRepository
 
std::shared_ptr< PagedRequestFetchermChatReplayMessagesFetcher
 
std::shared_ptr< BitsConfigurationmBitsConfiguration
 
RetryTimer mFetchVodRetryTimer
 
RetryTimer mFetchBitsConfigRetryTimer
 
WaitForExpiry mFetchMessagesRetryTimer
 
DisposerFunc mDisposerFunc
 
TokenizationOptions mTokenizationOptions
 
uint64_t mLastUpdateTimeMilliseconds
 
uint64_t mPlayheadTimeMilliseconds
 
uint64_t mLastLoadedTimeMilliseconds
 
Timestamp mVodRecordedAtSeconds
 
uint32_t mSeekCount
 
UserId mUserId
 
ChannelId mChannelId
 
ChatReplayState mReplayState
 
bool mVodFetchInFlight
 
bool mBitsConfigFetchInFlight
 
bool mHasFetchedVod
 
bool mHasFetchedBitsConfig
 
bool mHasNoMessages
 

Class Documentation

◆ ttv::chat::ChatReplay::ReplayMessageBatch

struct ttv::chat::ChatReplay::ReplayMessageBatch
Class Members
uint64_t baseTimestamp
vector< ReplayMessage > messages

Member Typedef Documentation

◆ DisposerFunc

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

Member Enumeration Documentation

◆ State

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

The component doesn't require shutting down.

Constructor & Destructor Documentation

◆ ChatReplay()

ttv::chat::ChatReplay::ChatReplay ( const std::shared_ptr< User > &  user)

Member Function Documentation

◆ AddListener()

void ttv::chat::ChatReplay::AddListener ( const std::shared_ptr< IChatReplayListener > &  listener)
inline

◆ Advance()

void ttv::chat::ChatReplay::Advance ( )
private

◆ CheckShutdown()

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

◆ CompleteShutdown()

virtual void ttv::chat::ChatReplay::CompleteShutdown ( )
overridevirtual

Reimplemented from ttv::Component.

◆ CompleteTask()

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

◆ DeleteMessage()

virtual TTV_ErrorCode ttv::chat::ChatReplay::DeleteMessage ( const std::string &  messageId)
overridevirtual

Deletes the given message from the replay on the backend so that it cannot be viewed by any other users. The user's OAuth token must have permission to perform the deletion.

Implements ttv::chat::IChatReplay.

◆ Dispose()

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

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

Implements ttv::chat::IChatReplay.

◆ FetchBitsConfig()

TTV_ErrorCode ttv::chat::ChatReplay::FetchBitsConfig ( )
private

◆ FetchChatReplayMessagesAtMillisecond()

TTV_ErrorCode ttv::chat::ChatReplay::FetchChatReplayMessagesAtMillisecond ( uint64_t  timestamp)
private

◆ FetchVod()

TTV_ErrorCode ttv::chat::ChatReplay::FetchVod ( )
private

◆ GetChannelId()

virtual TTV_ErrorCode ttv::chat::ChatReplay::GetChannelId ( UserId result) const
overridevirtual

Puts the channel ID in result.

Implements ttv::chat::IChatReplay.

◆ GetCurrentTime()

virtual TTV_ErrorCode ttv::chat::ChatReplay::GetCurrentTime ( Timestamp timestamp) const
overridevirtual

Retrieves the time for the playhead.

Implements ttv::chat::IChatReplay.

◆ GetLoggerName()

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

Implements ttv::Component.

◆ GetReplayState()

virtual TTV_ErrorCode ttv::chat::ChatReplay::GetReplayState ( ChatReplayState result) const
overridevirtual

Puts the current replay state in result. Set to PAUSED initially.

Implements ttv::chat::IChatReplay.

◆ GetState()

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

Implements ttv::IComponent.

◆ GetTaskRunner()

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

◆ GetVodId()

std::string ttv::chat::ChatReplay::GetVodId ( ) const
inline

◆ Initialize()

virtual TTV_ErrorCode ttv::chat::ChatReplay::Initialize ( )
overridevirtual

Reimplemented from ttv::Component.

◆ IsTaskRunning()

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

◆ NudgePlayhead()

virtual TTV_ErrorCode ttv::chat::ChatReplay::NudgePlayhead ( uint64_t  timestampMilliseconds)
overridevirtual

Moves the playhead to absolute time in milliseconds, should be called periodically by the player to correct millisecond clock drift.

Implements ttv::chat::IChatReplay.

◆ Pause()

virtual TTV_ErrorCode ttv::chat::ChatReplay::Pause ( )
overridevirtual

Pauses the playhead. Should be called when the video player's pause is called, or when the video player starts buffering.

Implements ttv::chat::IChatReplay.

◆ Play()

virtual TTV_ErrorCode ttv::chat::ChatReplay::Play ( )
overridevirtual

Initiates playback of the messages and causes the playhead to advance. Should be called when the video player starts playing, or resumes from buffering, with a NudgePlayhead() if necessary. Has no effect when current ChatReplayState is BUFFERING, because playback will automatically resume when done buffering.

Implements ttv::chat::IChatReplay.

◆ Seek()

virtual TTV_ErrorCode ttv::chat::ChatReplay::Seek ( Timestamp  timestamp)
overridevirtual

Sets the current playhead time to be the given time. If the state is playing this may cause buffering if the messages around the given time are not locally cached.

Implements ttv::chat::IChatReplay.

◆ SetBitsConfigRepository()

void ttv::chat::ChatReplay::SetBitsConfigRepository ( const std::shared_ptr< BitsConfigRepository > &  repository)
inline

◆ SetChannelRepository()

void ttv::chat::ChatReplay::SetChannelRepository ( const std::shared_ptr< ChannelRepository > &  repository)
inline

◆ SetClientState()

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

◆ SetDisposer()

void ttv::chat::ChatReplay::SetDisposer ( DisposerFunc &&  func)
inline

◆ SetReplayState()

void ttv::chat::ChatReplay::SetReplayState ( ChatReplayState  state)
private

◆ 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

◆ SetTokenizationOptions()

void ttv::chat::ChatReplay::SetTokenizationOptions ( const TokenizationOptions tokenizationOptions)
inline

◆ SetVodId()

void ttv::chat::ChatReplay::SetVodId ( const std::string &  vodId)

◆ Shutdown()

virtual TTV_ErrorCode ttv::chat::ChatReplay::Shutdown ( )
overridevirtual

Reimplemented from ttv::Component.

◆ StartTask()

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

◆ Update()

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

Reimplemented from ttv::Component.

Member Data Documentation

◆ mBitsConfigFetchInFlight

bool ttv::chat::ChatReplay::mBitsConfigFetchInFlight
private

◆ mBitsConfigRepository

std::shared_ptr<BitsConfigRepository> ttv::chat::ChatReplay::mBitsConfigRepository
private

◆ mBitsConfiguration

std::shared_ptr<BitsConfiguration> ttv::chat::ChatReplay::mBitsConfiguration
private

◆ mChannelId

ChannelId ttv::chat::ChatReplay::mChannelId
private

◆ mChannelRepository

std::shared_ptr<ChannelRepository> ttv::chat::ChatReplay::mChannelRepository
private

◆ mChatReplayMessagesFetcher

std::shared_ptr<PagedRequestFetcher> ttv::chat::ChatReplay::mChatReplayMessagesFetcher
private

◆ mDisposerFunc

DisposerFunc ttv::chat::ChatReplay::mDisposerFunc
private

◆ mFetchBitsConfigRetryTimer

RetryTimer ttv::chat::ChatReplay::mFetchBitsConfigRetryTimer
private

◆ mFetchedLists

std::vector<ReplayMessageBatch> ttv::chat::ChatReplay::mFetchedLists
private

◆ mFetchMessagesRetryTimer

WaitForExpiry ttv::chat::ChatReplay::mFetchMessagesRetryTimer
private

◆ mFetchVodRetryTimer

RetryTimer ttv::chat::ChatReplay::mFetchVodRetryTimer
private

◆ mHasFetchedBitsConfig

bool ttv::chat::ChatReplay::mHasFetchedBitsConfig
private

◆ mHasFetchedVod

bool ttv::chat::ChatReplay::mHasFetchedVod
private

◆ mHasNoMessages

bool ttv::chat::ChatReplay::mHasNoMessages
private

◆ mLastLoadedTimeMilliseconds

uint64_t ttv::chat::ChatReplay::mLastLoadedTimeMilliseconds
private

◆ mLastUpdateTimeMilliseconds

uint64_t ttv::chat::ChatReplay::mLastUpdateTimeMilliseconds
private

◆ mListeners

EventSource<IChatReplayListener> ttv::chat::ChatReplay::mListeners
private

◆ mPlayheadTimeMilliseconds

uint64_t ttv::chat::ChatReplay::mPlayheadTimeMilliseconds
private

◆ mReplayState

ChatReplayState ttv::chat::ChatReplay::mReplayState
private

◆ mRunningTasks

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

◆ mSeekCount

uint32_t ttv::chat::ChatReplay::mSeekCount
private

◆ 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

◆ mTokenizationOptions

TokenizationOptions ttv::chat::ChatReplay::mTokenizationOptions
private

◆ mUser

std::shared_ptr<User> ttv::chat::ChatReplay::mUser
private

◆ mUserId

UserId ttv::chat::ChatReplay::mUserId
private

◆ mVodFetchInFlight

bool ttv::chat::ChatReplay::mVodFetchInFlight
private

◆ mVodId

std::string ttv::chat::ChatReplay::mVodId
private

◆ mVodRecordedAtSeconds

Timestamp ttv::chat::ChatReplay::mVodRecordedAtSeconds
private

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