Twitch SDK (Internal)
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::ChatRoom Class Reference

#include <chatroom.h>

Inheritance diagram for ttv::chat::ChatRoom:
ttv::chat::IChatRoom ttv::PubSubComponent< IChatRoomListener > ttv::PubSubComponentBase ttv::UserComponent ttv::Component ttv::IComponent

Public Types

using DisposerFunc = std::function< void()>
 
using DeleteRoomCallback = std::function< void(TTV_ErrorCode ec)>
 
using SendMessageCallback = std::function< void(TTV_ErrorCode ec, SendRoomMessageError &&error, ChatRoomMessage &&message)>
 
using EditMessageCallback = std::function< void(TTV_ErrorCode ec, ChatRoomMessage &&message)>
 
using DeleteMessageCallback = std::function< void(TTV_ErrorCode ec)>
 
using FetchMessagesCallback = std::function< void(TTV_ErrorCode ec, std::vector< ChatRoomMessage > &&messages, std::string &&nextCursor, bool moreMessages)>
 
using UpdateRoomInfoCallback = std::function< void(TTV_ErrorCode ec, UpdateRoomError &&error, ChatRoomInfo &&info)>
 
using UpdateRoomModesCallback = std::function< void(TTV_ErrorCode ec, UpdateRoomModesError &&error, ChatRoomInfo &&info)>
 
using UpdateRoomViewCallback = std::function< void(TTV_ErrorCode ec, ChatRoomInfo &&info)>
 
using FetchRoomInfoCallback = std::function< void(TTV_ErrorCode ec, ChatRoomInfo &&info)>
 
enum  State { State::Uninitialized, State::Initialized, State::ShuttingDown, State::Inert }
 

Public Member Functions

 ChatRoom (const std::shared_ptr< User > &user, const std::string &roomId, ChannelId channelId)
 
virtual std::string GetLoggerName () const override
 
virtual void Update () override
 
virtual TTV_ErrorCode Dispose () override
 
virtual TTV_ErrorCode DeleteRoom (const DeleteRoomCallback &callback) override
 
virtual TTV_ErrorCode SendMessage (const std::string &message, ChatRoomMessage &placeholderMessage, const SendMessageCallback &callback) override
 
virtual TTV_ErrorCode EditMessage (const std::string &messageId, const std::string &message, ChatRoomMessage &placeholderMessage, const EditMessageCallback &callback) override
 
virtual TTV_ErrorCode DeleteMessage (const std::string &messageId, const DeleteMessageCallback &callback) override
 
virtual TTV_ErrorCode FetchMessagesBeforeCursor (const std::string &cursor, uint32_t limit, const FetchMessagesCallback &callback) override
 
virtual TTV_ErrorCode FetchMessagesAfterCursor (const std::string &cursor, uint32_t limit, const FetchMessagesCallback &callback) override
 
virtual TTV_ErrorCode FetchMessagesBeforeTimestamp (Timestamp timestamp, uint32_t limit, const FetchMessagesCallback &callback) override
 
virtual TTV_ErrorCode FetchMessagesAfterTimestamp (Timestamp timestamp, uint32_t limit, const FetchMessagesCallback &callback) override
 
virtual TTV_ErrorCode FetchRoomInfo (const FetchRoomInfoCallback &callback) override
 
virtual TTV_ErrorCode SetRoomName (const std::string &name, const UpdateRoomInfoCallback &callback) override
 
virtual TTV_ErrorCode SetTopic (const std::string &topic, const UpdateRoomInfoCallback &callback) override
 
virtual TTV_ErrorCode SetPreviewable (bool isPreviewable, const UpdateRoomInfoCallback &callback) override
 
virtual TTV_ErrorCode SetMinimumAllowedRole (RoomRole minimumAllowedRole, const UpdateRoomInfoCallback &callback) override
 
virtual TTV_ErrorCode EnableSlowMode (uint32_t durationSeconds, const UpdateRoomModesCallback &callback) override
 
virtual TTV_ErrorCode DisableSlowMode (const UpdateRoomModesCallback &callback) override
 
virtual TTV_ErrorCode EnableR9kMode (const UpdateRoomModesCallback &callback) override
 
virtual TTV_ErrorCode DisableR9kMode (const UpdateRoomModesCallback &callback) override
 
virtual TTV_ErrorCode EnableEmotesOnlyMode (const UpdateRoomModesCallback &callback) override
 
virtual TTV_ErrorCode DisableEmotesOnlyMode (const UpdateRoomModesCallback &callback) override
 
virtual TTV_ErrorCode SetLastReadAt (Timestamp lastReadAt, const UpdateRoomViewCallback &callback) override
 
virtual TTV_ErrorCode SetMuted (bool isMuted, const UpdateRoomViewCallback &callback) override
 
virtual TTV_ErrorCode SetArchived (bool isArchived, const UpdateRoomViewCallback &callback) override
 
void SetTokenizationOptions (const TokenizationOptions &options)
 
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< IChatRoomListener > &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< IChatRoomListenermListener
 
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

TTV_ErrorCode TokenizeLocalMessage (const std::shared_ptr< User > &user, const std::string &message, ChatRoomMessage &chatMessage)
 
TTV_ErrorCode SetChatMode (ChatMode mode, bool turnOn, uint32_t slowModeDurationSeconds, const UpdateRoomModesCallback &callback)
 
void FlagIgnoredMessages (std::vector< ChatRoomMessage > &messages)
 

Private Attributes

std::unordered_map< std::string, uint64_t > mMessageNonces
 Keeps track of sent message nonces to prevent duplicates from pubsub. More...
 
std::vector< MessageBadgemCachedUserBadges
 Cache the user's badges received from the last API callback to use for the next placeholder message's badges. More...
 
std::string mPubSubTopic
 
std::string mRoomId
 
TokenizationOptions mTokenizationOptions
 
ChannelId mChannelId
 
Color mCachedUserColor
 Cache the user's chat color received from the last API callback to use for the next placeholder message's chat color. More...
 

Member Typedef Documentation

◆ DeleteMessageCallback

using ttv::chat::IChatRoom::DeleteMessageCallback = std::function<void(TTV_ErrorCode ec)>
inherited

Used with DeleteMessage().

Parameters
[in]ec
  • TTV_EC_SUCCESS: The message was successfully deleted.
  • TTV_EC_WEBAPI_RESULT_INVALID_JSON: Something went wrong when trying to delete the message.
[in]messageThe message received back from the server.

◆ DeleteRoomCallback

using ttv::chat::IChatRoom::DeleteRoomCallback = std::function<void(TTV_ErrorCode ec)>
inherited

Used with DeleteRoom().

Parameters
[in]ec
  • TTV_EC_SUCCESS: The room was successfully deleted.
  • TTV_EC_WEBAPI_RESULT_INVALID_JSON: Something went wrong when trying to delete the room.

◆ DisposerFunc

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

◆ EditMessageCallback

using ttv::chat::IChatRoom::EditMessageCallback = std::function<void(TTV_ErrorCode ec, ChatRoomMessage&& message)>
inherited

Used with EditMessage().

Parameters
[in]ec
  • TTV_EC_SUCCESS: The message was successfully edited.
  • TTV_EC_WEBAPI_RESULT_INVALID_JSON: Something went wrong when trying to edit the message.
[in]messageThe message received back from the server.

◆ FetchMessagesCallback

using ttv::chat::IChatRoom::FetchMessagesCallback = std::function<void(TTV_ErrorCode ec, std::vector<ChatRoomMessage>&& messages, std::string&& nextCursor, bool moreMessages)>
inherited

Used with FetchMessages functions.

Parameters
[in]ec
  • TTV_EC_SUCCESS: The messages were retrieved.
  • TTV_EC_WEBAPI_RESULT_INVALID_JSON: Something went wrong when trying to fetch the messages.
[in]messagesThe list of messages received back from the server. If fetching before a time/cursor, listed from newest to oldest. Else if fetching after a time/cursor, listed from oldest to newest.
[in]nextCursorThe cursor to use next time to fetch messages from where we left off, in the same pagination direction.
[in]moreMessagesTrue if there are more messages to be fetched at the cursor, else false.

◆ FetchRoomInfoCallback

using ttv::chat::IChatRoom::FetchRoomInfoCallback = std::function<void(TTV_ErrorCode ec, ChatRoomInfo&& info)>
inherited

Used with FetchRoomInfo().

Parameters
[in]ec
  • TTV_EC_SUCCESS: The room info was retrieved.
  • TTV_EC_WEBAPI_RESULT_INVALID_JSON: Something went wrong when trying to retrieve the room info.
[in]infoThe updated information of the room.

◆ SendMessageCallback

using ttv::chat::IChatRoom::SendMessageCallback = std::function<void(TTV_ErrorCode ec, SendRoomMessageError&& error, ChatRoomMessage&& message)>
inherited

Used with SendMessage().

Parameters
[in]ec
  • TTV_EC_SUCCESS: The message was successfully sent.
  • TTV_EC_WEBAPI_RESULT_INVALID_JSON: Received an invalid response from the back-end.
  • TTV_EC_GRAPHQL_ERROR: Received an error code from the back-end.
[in]errorError object received from GraphQL describing reason why sending message failed.
[in]messageThe message received back from the server.

◆ UpdateRoomInfoCallback

using ttv::chat::IChatRoom::UpdateRoomInfoCallback = std::function<void(TTV_ErrorCode ec, UpdateRoomError&& error, ChatRoomInfo&& info)>
inherited

Used when updating the information of a room.

Parameters
[in]ec
  • TTV_EC_SUCCESS: The room info was changed.
  • TTV_EC_WEBAPI_RESULT_INVALID_JSON: Something went wrong when trying to change the room info.
  • TTV_EC_GRAPHQL_ERROR: Received an error code from the back-end.
[in]errorError object received from GraphQL describing the reason why updating room info failed.
[in]infoThe updated information of the room.

◆ UpdateRoomModesCallback

using ttv::chat::IChatRoom::UpdateRoomModesCallback = std::function<void(TTV_ErrorCode ec, UpdateRoomModesError&& error, ChatRoomInfo&& info)>
inherited

Used when updating a room's chat mode.

Parameters
[in]ec
  • TTV_EC_SUCCESS: The room's chat mode was changed.
  • TTV_EC_WEBAPI_RESULT_INVALID_JSON: Something went wrong when trying to change the room's chat mode.
  • TTV_EC_GRAPHQL_ERROR: Received an error code from the back-end.
[in]errorError object received from GraphQL describing the reason why updating room mode failed.
[in]infoThe updated information of the room.

◆ UpdateRoomViewCallback

using ttv::chat::IChatRoom::UpdateRoomViewCallback = std::function<void(TTV_ErrorCode ec, ChatRoomInfo&& info)>
inherited

Used when updating a room's view.

Parameters
[in]ec
  • TTV_EC_SUCCESS: The room's view was changed.
  • TTV_EC_WEBAPI_RESULT_INVALID_JSON: Something went wrong when trying to change the room's view.
[in]infoThe updated information of the room.

Member Enumeration Documentation

◆ State

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

The component doesn't require shutting down.

Constructor & Destructor Documentation

◆ ChatRoom()

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

Member Function Documentation

◆ 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< IChatRoomListener >::CompleteShutdown ( )
inlineoverridevirtualinherited

Reimplemented from ttv::PubSubComponentBase.

◆ CompleteTask()

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

◆ DeleteMessage()

virtual TTV_ErrorCode ttv::chat::ChatRoom::DeleteMessage ( const std::string &  messageId,
const DeleteMessageCallback callback 
)
overridevirtual

Deletes a message in the chat room.

Parameters
[in]messageIdThe id of the message we want to delete.
[in]callbackCallback when API call returns, receives an error code.
Returns
  • TTV_EC_SUCCESS: We've sent the request to delete the message.
  • 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::IChatRoom.

◆ DeleteRoom()

virtual TTV_ErrorCode ttv::chat::ChatRoom::DeleteRoom ( const DeleteRoomCallback callback)
overridevirtual

Deletes the chat room from the channel. User must be the owner of the chat room.

Parameters
[in]callbackCallback when API call returns, receives an error code.
Returns
  • TTV_EC_SUCCESS: We've sent the request to delete the room.
  • 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::IChatRoom.

◆ DisableEmotesOnlyMode()

virtual TTV_ErrorCode ttv::chat::ChatRoom::DisableEmotesOnlyMode ( const UpdateRoomModesCallback callback)
overridevirtual

Turns off emotes-only mode for the chat room.

Parameters
[in]callbackCallback when the API call returns, receives an error code and the new room info.
Returns
  • TTV_EC_SUCCESS: We've send the request to turn off emotes-only mode for the 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.

Implements ttv::chat::IChatRoom.

◆ DisableR9kMode()

virtual TTV_ErrorCode ttv::chat::ChatRoom::DisableR9kMode ( const UpdateRoomModesCallback callback)
overridevirtual

Turns off r9k mode for the chat room.

Parameters
[in]callbackCallback when the API call returns, receives an error code and the new room info.
Returns
  • TTV_EC_SUCCESS: We've send the request to turn off r9k mode for the 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.

Implements ttv::chat::IChatRoom.

◆ DisableSlowMode()

virtual TTV_ErrorCode ttv::chat::ChatRoom::DisableSlowMode ( const UpdateRoomModesCallback callback)
overridevirtual

Turns off slow mode for the chat room.

Parameters
[in]callbackCallback when the API call returns, receives an error code and the new room info.
Returns
  • TTV_EC_SUCCESS: We've send the request to turn off slow mode for the 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.

Implements ttv::chat::IChatRoom.

◆ Dispose()

virtual TTV_ErrorCode ttv::chat::ChatRoom::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::IChatRoom.

◆ EditMessage()

virtual TTV_ErrorCode ttv::chat::ChatRoom::EditMessage ( const std::string &  messageId,
const std::string &  message,
ChatRoomMessage placeholderMessage,
const EditMessageCallback callback 
)
overridevirtual

Edits a message's content in the chat room. User must have written the message.

Parameters
[in]messageIdThe id of the message we want to edit.
[in]messageThe content that we want to set the message to.
[out]placeholderMessageA ChatRoomMessage created client-side to be displayed until we receive the actual message result from the backend.
[in]callbackCallback when API call returns, receives an error code and the edited message.
Returns
  • TTV_EC_SUCCESS: We've sent the request to edit the message.
  • 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::IChatRoom.

◆ EnableEmotesOnlyMode()

virtual TTV_ErrorCode ttv::chat::ChatRoom::EnableEmotesOnlyMode ( const UpdateRoomModesCallback callback)
overridevirtual

Turns on emotes-only mode for the chat room.

Parameters
[in]callbackCallback when the API call returns, receives an error code and the new room info.
Returns
  • TTV_EC_SUCCESS: We've send the request to turn on emotes-only mode for the 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.

Implements ttv::chat::IChatRoom.

◆ EnableR9kMode()

virtual TTV_ErrorCode ttv::chat::ChatRoom::EnableR9kMode ( const UpdateRoomModesCallback callback)
overridevirtual

Turns on r9k mode for the chat room.

Parameters
[in]callbackCallback when the API call returns, receives an error code and the new room info.
Returns
  • TTV_EC_SUCCESS: We've send the request to turn on r9k mode for the 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.

Implements ttv::chat::IChatRoom.

◆ EnableSlowMode()

virtual TTV_ErrorCode ttv::chat::ChatRoom::EnableSlowMode ( uint32_t  durationSeconds,
const UpdateRoomModesCallback callback 
)
overridevirtual

Turns on slow mode for the chat room.

Parameters
[in]durationSecondsThe number of seconds a user must wait between sending messages. Cannot be 0.
[in]callbackCallback when the API call returns, receives an error code and the new room info.
Returns
  • TTV_EC_SUCCESS: We've send the request to turn on slow mode for the chat room.
  • TTV_EC_INVALID_ARG: durationSeconds cannot be 0.
  • 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::IChatRoom.

◆ FetchMessagesAfterCursor()

virtual TTV_ErrorCode ttv::chat::ChatRoom::FetchMessagesAfterCursor ( const std::string &  cursor,
uint32_t  limit,
const FetchMessagesCallback callback 
)
overridevirtual

Fetches newer messages from the chat room starting at the cursor, from oldest to newest.

Parameters
[in]cursorThe cursor that we want to start fetching messages from. If the empty string is passed in, we fetch the oldest messages in the room.
[in]limitThe max number of messages to fetch. Can be a number from 1-100.
[in]callbackCallback when API call returns, receives an error code and the list of messages.
Returns
  • TTV_EC_SUCCESS: We've sent the request to fetch the messages.
  • TTV_EC_INVALID_ARG: One of the parameters passed in is not a valid value.
  • 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::IChatRoom.

◆ FetchMessagesAfterTimestamp()

virtual TTV_ErrorCode ttv::chat::ChatRoom::FetchMessagesAfterTimestamp ( Timestamp  timestamp,
uint32_t  limit,
const FetchMessagesCallback callback 
)
overridevirtual

Fetches messages from the chat room and after the timestamp (inclusive), from oldest to newest.

Parameters
[in]timestampThe timestamp that we want to start fetching messages from.
[in]limitThe max number of messages to fetch. Can be a number from 1-100.
[in]callbackCallback when API call returns, receives an error code and the list of messages.
Returns
  • TTV_EC_SUCCESS: We've sent the request to fetch the messages.
  • TTV_EC_INVALID_ARG: One of the parameters passed in is not a valid value.
  • 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::IChatRoom.

◆ FetchMessagesBeforeCursor()

virtual TTV_ErrorCode ttv::chat::ChatRoom::FetchMessagesBeforeCursor ( const std::string &  cursor,
uint32_t  limit,
const FetchMessagesCallback callback 
)
overridevirtual

Fetches older messages from the chat room starting at the cursor, from newest to oldest.

Parameters
[in]cursorThe cursor that we want to start fetching messages from. If the empty string is passed in, we fetch the most recent messages in the room.
[in]limitThe max number of messages to fetch. Can be a number from 1-100.
[in]callbackCallback when API call returns, receives an error code and the list of messages.
Returns
  • TTV_EC_SUCCESS: We've sent the request to fetch the messages.
  • TTV_EC_INVALID_ARG: One of the parameters passed in is not a valid value.
  • 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::IChatRoom.

◆ FetchMessagesBeforeTimestamp()

virtual TTV_ErrorCode ttv::chat::ChatRoom::FetchMessagesBeforeTimestamp ( Timestamp  timestamp,
uint32_t  limit,
const FetchMessagesCallback callback 
)
overridevirtual

Fetches messages from the chat room before the timestamp, from newest to oldest.

Parameters
[in]timestampThe timestamp that we want to start fetching messages from.
[in]limitThe max number of messages to fetch. Can be a number from 1-100.
[in]callbackCallback when API call returns, receives an error code and the list of messages.
Returns
  • TTV_EC_SUCCESS: We've sent the request to fetch the messages.
  • TTV_EC_INVALID_ARG: One of the parameters passed in is not a valid value.
  • 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::IChatRoom.

◆ FetchRoomInfo()

virtual TTV_ErrorCode ttv::chat::ChatRoom::FetchRoomInfo ( const FetchRoomInfoCallback callback)
overridevirtual

Fetches the information of the chat room and returns it in the callback.

Parameters
[in]callbackCallback when API call returns, receives an error code and the room info.
Returns
  • TTV_EC_SUCCESS: We've sent the request to fetch the room info.
  • 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::IChatRoom.

◆ FlagIgnoredMessages()

void ttv::chat::ChatRoom::FlagIgnoredMessages ( std::vector< ChatRoomMessage > &  messages)
private

◆ GetComponentName()

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

◆ GetLoggerName()

virtual std::string ttv::chat::ChatRoom::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

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

◆ OnTopicSubscribeStateChanged()

void ttv::chat::ChatRoom::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

◆ SendMessage()

virtual TTV_ErrorCode ttv::chat::ChatRoom::SendMessage ( const std::string &  message,
ChatRoomMessage placeholderMessage,
const SendMessageCallback callback 
)
overridevirtual

Send a message to the chat room. User must be joined to the chat room.

Parameters
[in]messageContent of the message we want to send to the chat room.
[out]placeholderMessageA ChatRoomMessage created client-side to be displayed until we receive the actual message result from the backend.
[in]callbackCallback when API call returns, receives an error code and the sent message.
Returns
  • TTV_EC_SUCCESS: We've sent the request to send the message.
  • 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::IChatRoom.

◆ SetArchived()

virtual TTV_ErrorCode ttv::chat::ChatRoom::SetArchived ( bool  isArchived,
const UpdateRoomViewCallback callback 
)
overridevirtual

Update if the user has archived the chat room.

Parameters
[in]isArchivedWhether the user has archived the room.
[in]callbackCallback when API call returns, receives an error code and the new room info.
Returns
  • TTV_EC_SUCCESS: We've sent the request to archive the room.
  • 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::IChatRoom.

◆ SetChatMode()

TTV_ErrorCode ttv::chat::ChatRoom::SetChatMode ( ChatMode  mode,
bool  turnOn,
uint32_t  slowModeDurationSeconds,
const UpdateRoomModesCallback callback 
)
private

◆ SetClientState()

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

◆ SetDisposer()

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

◆ SetLastReadAt()

virtual TTV_ErrorCode ttv::chat::ChatRoom::SetLastReadAt ( Timestamp  lastReadAt,
const UpdateRoomViewCallback callback 
)
overridevirtual

Update when the user last read a message in the chat room.

Parameters
[in]lastReadAtThe time the user last read a message.
[in]callbackCallback when API call returns, receives an error code and the new room info.
Returns
  • TTV_EC_SUCCESS: We've sent the request set the last read at time.
  • 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::IChatRoom.

◆ SetListener()

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

◆ SetMinimumAllowedRole()

virtual TTV_ErrorCode ttv::chat::ChatRoom::SetMinimumAllowedRole ( RoomRole  minimumAllowedRole,
const UpdateRoomInfoCallback callback 
)
overridevirtual

Update the minimum role required to join the chat room.

Parameters
[in]minimumAllowedRoleThe new minimum required role for the room.
[in]callbackCallback when API call returns, receives an error code and the new room info.
Returns
  • TTV_EC_SUCCESS: We've sent the request to set the room's minimum allowed role.
  • TTV_EC_INVALID_ARG: The room role passed in cannot be Unknown.
  • 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::IChatRoom.

◆ SetMuted()

virtual TTV_ErrorCode ttv::chat::ChatRoom::SetMuted ( bool  isMuted,
const UpdateRoomViewCallback callback 
)
overridevirtual

Update if the user has muted the chat room.

Parameters
[in]isMutedWhether the user has muted the room.
[in]callbackCallback when API call returns, receives an error code and the new room info.
Returns
  • TTV_EC_SUCCESS: We've sent the request to mute the room.
  • 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::IChatRoom.

◆ SetPreviewable()

virtual TTV_ErrorCode ttv::chat::ChatRoom::SetPreviewable ( bool  isPreviewable,
const UpdateRoomInfoCallback callback 
)
overridevirtual

Update whether the chat room is previewable to non-joined users.

Parameters
[in]isPreviewableWhether the chat room will be previewable.
[in]callbackCallback when API call returns, receives an error code and the new room info.
Returns
  • TTV_EC_SUCCESS: We've sent the request to set the room's previewability.
  • 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::IChatRoom.

◆ SetRoomName()

virtual TTV_ErrorCode ttv::chat::ChatRoom::SetRoomName ( const std::string &  name,
const UpdateRoomInfoCallback callback 
)
overridevirtual

Update the name of the chat room.

Parameters
[in]nameThe new name of the room.
[in]callbackCallback when API call returns, receives an error code and the new room info.
Returns
  • TTV_EC_SUCCESS: We've sent the request to set the room name.
  • 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::IChatRoom.

◆ 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::ChatRoom::SetTokenizationOptions ( const TokenizationOptions options)
inline

◆ SetTopic()

virtual TTV_ErrorCode ttv::chat::ChatRoom::SetTopic ( const std::string &  topic,
const UpdateRoomInfoCallback callback 
)
overridevirtual

Update the topic of the chat room.

Parameters
[in]nameThe new topic of the room.
[in]callbackCallback when API call returns, receives an error code and the new room info.
Returns
  • TTV_EC_SUCCESS: We've sent the request to set the room topic.
  • 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::IChatRoom.

◆ 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

◆ TokenizeLocalMessage()

TTV_ErrorCode ttv::chat::ChatRoom::TokenizeLocalMessage ( const std::shared_ptr< User > &  user,
const std::string &  message,
ChatRoomMessage chatMessage 
)
private

◆ Update()

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

Reimplemented from ttv::Component.

Member Data Documentation

◆ mCachedUserBadges

std::vector<MessageBadge> ttv::chat::ChatRoom::mCachedUserBadges
private

Cache the user's badges received from the last API callback to use for the next placeholder message's badges.

◆ mCachedUserColor

Color ttv::chat::ChatRoom::mCachedUserColor
private

Cache the user's chat color received from the last API callback to use for the next placeholder message's chat color.

◆ mChannelId

ChannelId ttv::chat::ChatRoom::mChannelId
private

◆ mDisposerFunc

DisposerFunc ttv::PubSubComponentBase::mDisposerFunc
protectedinherited

◆ mListener

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

◆ mMessageNonces

std::unordered_map<std::string, uint64_t> ttv::chat::ChatRoom::mMessageNonces
private

Keeps track of sent message nonces to prevent duplicates from pubsub.

◆ 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::ChatRoom::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

◆ mRoomId

std::string ttv::chat::ChatRoom::mRoomId
private

◆ 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

◆ mTokenizationOptions

TokenizationOptions ttv::chat::ChatRoom::mTokenizationOptions
private

◆ mUser

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

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