|
Twitch SDK (Internal)
|
#include <chatchannel.h>
Classes | |
| struct | State |
Public Types | |
| using | FetchUserListCallback = std::function< void(TTV_ErrorCode ec, UserList &&userList)> |
| using | SetBroadcasterLanguageChatCallback = std::function< void(TTV_ErrorCode ec)> |
| using | LookupId = uint64_t |
Public Member Functions | |
| ChatChannel (const std::shared_ptr< User > &user, ChannelId channelId, std::shared_ptr< IChatChannelListener > chatCallbacks, std::shared_ptr< TaskRunner > taskRunner) | |
| virtual | ~ChatChannel () |
| void | SetTokenizationOptions (const TokenizationOptions &options) |
| void | SetChannelRepository (const std::shared_ptr< ChannelRepository > &channelRepository) |
| void | SetBitsConfigRepository (const std::shared_ptr< BitsConfigRepository > &repository) |
| void | SetChatObjectFactory (std::shared_ptr< IChatObjectFactory > factory) |
| void | SetSettingRepository (std::shared_ptr< SettingRepository > settings) |
| TTV_ErrorCode | Connect () |
| TTV_ErrorCode | Disconnect () |
| TTV_ErrorCode | FlushClientEvents () |
| bool | IsShutdown () const |
| TTV_ErrorCode | SendChatMessage (const std::string &message) |
| TTV_ErrorCode | FetchUserList (const FetchUserListCallback &callback) |
| TTV_ErrorCode | SetBroadcasterLanguageChatEnabled (bool enabled, const SetBroadcasterLanguageChatCallback &callback) |
| TTV_ErrorCode | OptInToBroadcasterLanguageChat (const std::string &language) |
| TTV_ErrorCode | SetLocalLanguage (const std::string &language) |
| UserId | GetChannelId () const |
| void | SetMessageFlushInterval (uint64_t milliseconds) |
| uint64_t | GetMessageFlushInterval () const |
| ChatChannelState | GetState () const |
| std::shared_ptr< IChatChannelListener > | GetChannelListener () |
| std::shared_ptr< User > | GetUser () |
| virtual void | OnConnected (ChatConnection *source) override |
| virtual void | OnConnectionFailed (ChatConnection *source, TTV_ErrorCode ec) override |
| virtual void | OnConnectionLost (ChatConnection *source, TTV_ErrorCode ec) override |
| virtual void | OnCleared (ChatConnection *source, const std::string &username, const std::map< std::string, std::string > &messageTags) override |
| virtual void | OnPrivateMessageReceived (ChatConnection *source, const std::string &username, const std::string &message, const std::map< std::string, std::string > &messageTags, bool action) override |
| virtual void | OnUserNoticeReceived (ChatConnection *source, const std::string &message, const std::map< std::string, std::string > &messageTags) override |
| virtual void | OnUserStateChanged (ChatConnection *source, const std::map< std::string, std::string > &messageTags) override |
| virtual void | OnChatRestrictionsChanged (ChatConnection *source, const ChatChannelRestrictions &restrictions) override |
| virtual void | OnPermanentBanChanged (ChatConnection *source, bool banned) override |
| virtual void | OnTemporaryBanChanged (ChatConnection *source, bool temporarilyBanned, uint32_t timeout) override |
| virtual void | OnBadgesChanged (ChatConnection *source, const std::string &username, const std::string &badgesMessageTag) override |
| virtual void | OnHostTargetChanged (ChatConnection *source, const std::string &targetChannel, uint32_t numViewers) override |
| virtual void | OnNoticeReceived (ChatConnection *source, const std::string &id, const std::map< std::string, std::string > ¶ms) override |
| virtual void | OnIgnoreChanged (ChatConnection *source, const std::string &blockUserName, bool ignore) override |
Private Types | |
| using | ThreadEvent = std::function< void()> |
Private Member Functions | |
| void | FlushUserMessages (bool force) |
| void | ForceShutdown () |
| TTV_ErrorCode | ProcessClientRequestQueue () |
| TTV_ErrorCode | ProcessClientChatMessage (const std::string &msg) |
| TTV_ErrorCode | FetchChannelInfo () |
| TTV_ErrorCode | FetchChatProperties () |
| TTV_ErrorCode | FetchBitsConfiguration () |
| TTV_ErrorCode | ProcessDisconnectRequest () |
| TTV_ErrorCode | ProcessOptInToBroadcasterLanguageChatRequest (const std::string &language) |
| TTV_ErrorCode | ProcessSetLocalLanguageRequest (const std::string &language) |
| TTV_ErrorCode | ProcessChannelInfoFetchResult (const ChannelInfo &channelInfo) |
| TTV_ErrorCode | ProcessChatPropertyFetchResult (TTV_ErrorCode ec, std::shared_ptr< ChatPropertiesTask::Result > result) |
| TTV_ErrorCode | ProcessBitsConfigFetchResult (TTV_ErrorCode ec, const std::shared_ptr< BitsConfiguration > &config) |
| void | SetClientChannelInfo (const ChatChannelInfo &channelInfo) |
| void | SetClientChatRestrictions (const ChatChannelRestrictions &restrictions) |
| void | HandleMessageReceived (const std::string &username, const std::string &message, const std::map< std::string, std::string > &messageTags, const MessageInfo::Flags &flags) |
| void | HandleUserNotice (const std::string &message, const std::map< std::string, std::string > &messageTags) |
| void | HandleSubscriptionNotice (SubscriptionNotice::Type type, const std::string &message, const std::map< std::string, std::string > &messageTags) |
| void | HandleFirstTimeChatterNotice (const std::string &message, const std::map< std::string, std::string > &messageTags) |
| void | HandleRaidNotice (const std::string &message, const std::map< std::string, std::string > &messageTags) |
| void | HandleUnraidNotice (const std::string &message, const std::map< std::string, std::string > &messageTags) |
| void | GenerateUserInfo (const std::string &username, const std::map< std::string, std::string > &messageTags, ChatUserInfo &userInfo) |
| void | GenerateMessage (MessageInfo &msg, const TokenizationOptions &tokenizationOptions, const ChatUserInfo &userInfo, const std::string &message, const std::map< std::string, std::string > &messageTags, const MessageInfo::Flags &flags) |
| void | GenerateLiveMessage (LiveChatMessage &msg, const TokenizationOptions &tokenizationOptions, const ChatUserInfo &userInfo, const std::string &message, const std::map< std::string, std::string > &messageTags, const MessageInfo::Flags &flags) |
| void | ThreadProc () |
| void | CompleteShutdown () |
| bool | UpdateRestriction () |
| void | UpdateBroadcasterLanguageChatState () |
| TTV_ErrorCode | AttemptConnection () |
| void | CloseConnection () |
| void | SetState (State::Enum state) |
| void | HandleConnectionIssue (bool recoverableError) |
Private Attributes | |
| std::string | mBroadcasterName |
| std::shared_ptr< IChatChannelListener > | mChatCallbacks |
| Client-configured callbacks for chat notifications for this channel. More... | |
| std::shared_ptr< ChatPropertiesTask::Result > | mChatProperties |
| The chat properties for the channel. More... | |
| std::vector< std::string > | mHosts |
| The hosts to use to connect to the channel. More... | |
| std::shared_ptr< IChatObjectFactory > | mChatObjectFactory |
| The internal chat object factory. More... | |
| std::shared_ptr< IThread > | mChatThread |
| The thread managing the socket. More... | |
| std::shared_ptr< ChatConnection > | mChatConnection |
| The active connection. More... | |
| std::shared_ptr< ChannelRepository > | mChannelRepository |
| std::shared_ptr< SettingRepository > | mSettingRepository |
| std::shared_ptr< BitsConfigRepository > | mBitsConfigRepository |
| std::shared_ptr< TaskRunner > | mTaskRunner |
| std::shared_ptr< TaskRunner > | mBackgroundTaskRunner |
| WaitForExpiry | mFetchChatPropertiesTimer |
| The timer to use for fetching chat properties. More... | |
| WaitForExpiry | mFetchBitsConfigTimer |
| The timer to use for fetching the channel's bit configuration. More... | |
| RetryTimer | mConnectionRetryTimer |
| The master timer to use for connection retries. More... | |
| int | mNextChatHostIndex |
| The next chat host to connect to. More... | |
| ConcurrentQueue< ThreadEvent > | mToMainQ |
| The queue for messages from the chat thread to main thread. More... | |
| ConcurrentQueue< ThreadEvent > | mToChatQ |
| The queue for messages from the main thread to chat thread. More... | |
| std::vector< LiveChatMessage > | mUserMessageBatch |
| A batch of messages to be sent together to the client instead of one at a time (for performance). More... | |
| uint64_t | mUserMessageFlushInterval |
| The max amount of time between user message flushes to the main thread. More... | |
| WaitForExpiry | mNextUserMessageFlush |
| The next time in which to automatically flush all user messages to the main thread. More... | |
| ChatMessagePacer | mMessagePacer |
| Prevents the local user from sending too many messages too close together in time and getting banned. More... | |
| WaitForExpiry | mSlowModeTimer |
| When the channel is in slow mode this will mark the time when the next message is allowed. More... | |
| WaitForExpiry | mTimeoutTimer |
| When the user has been banned for a temporary amount of time this will mark the time when the next message is allowed. More... | |
| TTV_ErrorCode | mConnectionError |
| State::Enum | mChannelState |
| The current state, accessed only through the chat thread. More... | |
| ChatChannelState | mReportedClientState |
| The last reported state. More... | |
| ChatUserInfo | mSystemUserInfo |
| The display information for messages from JTV or TwitchNotify. More... | |
| ChatUserInfo | mClientLocalUserInfo |
| The info for the local user on the client thread. More... | |
| ChatUserInfo | mServerLocalUserInfo |
| The info for the local user on the chat thread. More... | |
| ChatChannelInfo | mClientChannelInfo |
| The current channel information as the client sees it. More... | |
| ChatChannelInfo | mServerChannelInfo |
| The current channel information on the chat thread. More... | |
| ChatChannelRestrictions | mClientChatRestrictions |
| The chat restrictions that are active for the channel as the client sees it. More... | |
| ChatChannelRestrictions | mServerChatRestrictions |
| The chat restrictions that are active for the channel on the chat thread. More... | |
| std::weak_ptr< User > | mUser |
| std::vector< std::string > | mQueuedChatMessages |
More... | |
| std::shared_ptr< BitsConfiguration > | mBitsConfiguration |
| std::string | mLocalLanguage |
| The language used by the local user. More... | |
| TokenizationOptions | mTokenizationOptions |
| Marks what to tokenize in a message. More... | |
| LookupId | mBitsConfigFetchToken |
| The cancellation token for fetching the BitsConfiguration. More... | |
| ChannelId | mChannelId |
| The ID of the channel. More... | |
| std::atomic< uint32_t > | mNumOutstandingTasks |
| bool | mApplySlowMode |
| bool | mAnonymous |
| Whether or not connecting anonymously to the channel. More... | |
| bool | mDisconnectionRequested |
| Whether or not the request to disconnect has been satisfied (callback fired to client). More... | |
| bool | mBroadcasterLanguageMatch |
| Whether or not the local language matches the active native chat language. More... | |
| bool | mBroadcasterLanguageOptedIn |
| Whether or not the user opted in to native language chat. More... | |
Provides the functionality for accessing a chat channel.
| using ttv::chat::ChatChannel::FetchUserListCallback = std::function<void(TTV_ErrorCode ec, UserList&& userList)> |
| using ttv::chat::ChatChannel::LookupId = uint64_t |
| using ttv::chat::ChatChannel::SetBroadcasterLanguageChatCallback = std::function<void(TTV_ErrorCode ec)> |
|
private |
| ttv::chat::ChatChannel::ChatChannel | ( | const std::shared_ptr< User > & | user, |
| ChannelId | channelId, | ||
| std::shared_ptr< IChatChannelListener > | chatCallbacks, | ||
| std::shared_ptr< TaskRunner > | taskRunner | ||
| ) |
|
virtual |
|
private |
|
private |
|
private |
Free the resources used by the chat thread.
| TTV_ErrorCode ttv::chat::ChatChannel::Connect | ( | ) |
Connect to the channel.
| TTV_ErrorCode ttv::chat::ChatChannel::Disconnect | ( | ) |
Disconnect from the channel.
|
private |
|
private |
|
private |
| TTV_ErrorCode ttv::chat::ChatChannel::FetchUserList | ( | const FetchUserListCallback & | callback | ) |
| TTV_ErrorCode ttv::chat::ChatChannel::FlushClientEvents | ( | ) |
Flushes events to the main thread for the game to process. This should only be called on the main thread.
|
private |
|
private |
This waits for the chat thread to close and blocks until it is safe to free the Channel instance.
|
private |
|
private |
|
private |
|
inline |
Retrieves the channel ID.
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
inline |
Determines whether the channel is disconnected and ready to be destroyed.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
|
overridevirtual |
Implements ttv::chat::ChatConnection::Listener.
| TTV_ErrorCode ttv::chat::ChatChannel::OptInToBroadcasterLanguageChat | ( | const std::string & | language | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
Handle requests from the main thread in the chat thread. This will create internal events and may initiate messages to the chat server. This should only be called on the chat thread.
|
private |
|
private |
|
private |
| TTV_ErrorCode ttv::chat::ChatChannel::SendChatMessage | ( | const std::string & | message | ) |
Sends a message from the current user.
|
inline |
| TTV_ErrorCode ttv::chat::ChatChannel::SetBroadcasterLanguageChatEnabled | ( | bool | enabled, |
| const SetBroadcasterLanguageChatCallback & | callback | ||
| ) |
|
inline |
| void ttv::chat::ChatChannel::SetChatObjectFactory | ( | std::shared_ptr< IChatObjectFactory > | factory | ) |
Sets the factory for creating custom implementation of chat components.
|
private |
|
private |
| TTV_ErrorCode ttv::chat::ChatChannel::SetLocalLanguage | ( | const std::string & | language | ) |
|
inline |
| void ttv::chat::ChatChannel::SetSettingRepository | ( | std::shared_ptr< SettingRepository > | settings | ) |
|
private |
|
inline |
|
private |
The thread which listens for incoming messages from the chat server.
|
private |
|
private |
|
private |
Whether or not connecting anonymously to the channel.
|
private |
|
private |
|
private |
The cancellation token for fetching the BitsConfiguration.
|
private |
|
private |
|
private |
Whether or not the local language matches the active native chat language.
|
private |
Whether or not the user opted in to native language chat.
|
private |
|
private |
The ID of the channel.
|
private |
|
private |
The current state, accessed only through the chat thread.
|
private |
Client-configured callbacks for chat notifications for this channel.
|
private |
The active connection.
|
private |
The internal chat object factory.
|
private |
The chat properties for the channel.
|
private |
The thread managing the socket.
|
private |
The current channel information as the client sees it.
|
private |
The chat restrictions that are active for the channel as the client sees it.
|
private |
The info for the local user on the client thread.
|
private |
|
private |
The master timer to use for connection retries.
|
private |
Whether or not the request to disconnect has been satisfied (callback fired to client).
|
private |
The timer to use for fetching the channel's bit configuration.
|
private |
The timer to use for fetching chat properties.
|
private |
The hosts to use to connect to the channel.
|
private |
The language used by the local user.
|
private |
Prevents the local user from sending too many messages too close together in time and getting banned.
|
private |
The next chat host to connect to.
|
private |
The next time in which to automatically flush all user messages to the main thread.
|
private |
|
private |
The local user connecting to the channel.
|
private |
The last reported state.
|
private |
The current channel information on the chat thread.
|
private |
The chat restrictions that are active for the channel on the chat thread.
|
private |
The info for the local user on the chat thread.
|
private |
|
private |
When the channel is in slow mode this will mark the time when the next message is allowed.
|
private |
The display information for messages from JTV or TwitchNotify.
|
private |
|
private |
When the user has been banned for a temporary amount of time this will mark the time when the next message is allowed.
|
private |
The queue for messages from the main thread to chat thread.
|
private |
Marks what to tokenize in a message.
|
private |
The queue for messages from the chat thread to main thread.
|
private |
|
private |
A batch of messages to be sent together to the client instead of one at a time (for performance).
|
private |
The max amount of time between user message flushes to the main thread.
1.8.13