28 class SettingRepository;
36 class ChatUserBlockList;
37 class BitsConfigRepository;
65 ChatChannel(
const std::shared_ptr<User>& user,
ChannelId channelId, std::shared_ptr<IChatChannelListener> chatCallbacks, std::shared_ptr<TaskRunner> taskRunner);
120 virtual void OnCleared(
ChatConnection* source,
const std::string& username,
const std::map<std::string, std::string>& messageTags)
override;
121 virtual void OnPrivateMessageReceived(
ChatConnection* source,
const std::string& username,
const std::string& message,
const std::map<std::string, std::string>& messageTags,
bool action)
override;
158 void HandleUserNotice(
const std::string& message,
const std::map<std::string, std::string>& messageTags);
161 void HandleRaidNotice(
const std::string& message,
const std::map<std::string, std::string>& messageTags);
162 void HandleUnraidNotice(
const std::string& message,
const std::map<std::string, std::string>& messageTags);
ConcurrentQueue< ThreadEvent > mToChatQ
The queue for messages from the main thread to chat thread.
Definition: chatchannel.h:205
uint32_t UserId
Definition: coretypes.h:22
std::shared_ptr< User > GetUser()
Definition: chatchannel.h:114
uint64_t GetMessageFlushInterval() const
Definition: chatchannel.h:109
Definition: chattypes.h:329
ChatChannelInfo mServerChannelInfo
The current channel information on the chat thread.
Definition: chatchannel.h:224
ChannelId mChannelId
The ID of the channel.
Definition: chatchannel.h:236
Definition: chattypes.h:161
virtual void OnIgnoreChanged(ChatConnection *source, const std::string &blockUserName, bool ignore) override
void FlushUserMessages(bool force)
virtual void OnUserNoticeReceived(ChatConnection *source, const std::string &message, const std::map< std::string, std::string > &messageTags) override
void HandleFirstTimeChatterNotice(const std::string &message, const std::map< std::string, std::string > &messageTags)
WaitForExpiry mTimeoutTimer
When the user has been banned for a temporary amount of time this will mark the time when the next me...
Definition: chatchannel.h:213
TTV_ErrorCode SetLocalLanguage(const std::string &language)
std::shared_ptr< ChatPropertiesTask::Result > mChatProperties
The chat properties for the channel.
Definition: chatchannel.h:186
Definition: chatchannel.h:56
Definition: chatchannel.h:54
void SetChannelRepository(const std::shared_ptr< ChannelRepository > &channelRepository)
Definition: chatchannel.h:69
ChatChannelRestrictions mClientChatRestrictions
The chat restrictions that are active for the channel as the client sees it.
Definition: chatchannel.h:225
TTV_ErrorCode ProcessOptInToBroadcasterLanguageChatRequest(const std::string &language)
int mNextChatHostIndex
The next chat host to connect to.
Definition: chatchannel.h:201
ChatUserInfo mServerLocalUserInfo
The info for the local user on the chat thread.
Definition: chatchannel.h:222
Definition: chattypes.h:299
bool mDisconnectionRequested
Whether or not the request to disconnect has been satisfied (callback fired to client).
Definition: chatchannel.h:242
void SetSettingRepository(std::shared_ptr< SettingRepository > settings)
void HandleSubscriptionNotice(SubscriptionNotice::Type type, const std::string &message, const std::map< std::string, std::string > &messageTags)
TTV_ErrorCode ProcessBitsConfigFetchResult(TTV_ErrorCode ec, const std::shared_ptr< BitsConfiguration > &config)
Definition: chatconnection.h:40
Definition: chattypes.h:169
TTV_ErrorCode ProcessChannelInfoFetchResult(const ChannelInfo &channelInfo)
TTV_ErrorCode FetchChannelInfo()
State::Enum mChannelState
The current state, accessed only through the chat thread.
Definition: chatchannel.h:217
void HandleUserNotice(const std::string &message, const std::map< std::string, std::string > &messageTags)
Definition: chatconnection.h:43
std::string mBroadcasterName
Definition: chatchannel.h:183
void HandleUnraidNotice(const std::string &message, const std::map< std::string, std::string > &messageTags)
Definition: chatchannel.h:55
ChatUserInfo mClientLocalUserInfo
The info for the local user on the client thread.
Definition: chatchannel.h:221
WaitForExpiry mFetchBitsConfigTimer
The timer to use for fetching the channel's bit configuration.
Definition: chatchannel.h:199
TTV_ErrorCode SendChatMessage(const std::string &message)
ChatChannelState GetState() const
Definition: chatchannel.h:111
Definition: chattypes.h:293
bool mBroadcasterLanguageOptedIn
Whether or not the user opted in to native language chat.
Definition: chatchannel.h:244
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
virtual void OnPermanentBanChanged(ChatConnection *source, bool banned) override
WaitForExpiry mSlowModeTimer
When the channel is in slow mode this will mark the time when the next message is allowed...
Definition: chatchannel.h:212
RetryTimer mConnectionRetryTimer
The master timer to use for connection retries.
Definition: chatchannel.h:200
std::vector< std::string > mQueuedChatMessages
The local user connecting to the channel.
Definition: chatchannel.h:229
std::shared_ptr< IChatChannelListener > GetChannelListener()
Definition: chatchannel.h:113
virtual void OnConnectionFailed(ChatConnection *source, TTV_ErrorCode ec) override
Enum
Definition: chatchannel.h:50
bool mAnonymous
Whether or not connecting anonymously to the channel.
Definition: chatchannel.h:241
uint64_t LookupId
Definition: chatchannel.h:63
void SetClientChatRestrictions(const ChatChannelRestrictions &restrictions)
Definition: chathelpers.h:35
Definition: chatchannel.h:48
ChatChannelInfo mClientChannelInfo
The current channel information as the client sees it.
Definition: chatchannel.h:223
TTV_ErrorCode ProcessClientRequestQueue()
std::shared_ptr< SettingRepository > mSettingRepository
Definition: chatchannel.h:193
void UpdateBroadcasterLanguageChatState()
std::shared_ptr< IChatObjectFactory > mChatObjectFactory
The internal chat object factory.
Definition: chatchannel.h:189
bool IsShutdown() const
Definition: chatchannel.h:92
std::function< void()> ThreadEvent
Definition: chatchannel.h:203
std::shared_ptr< IThread > mChatThread
The thread managing the socket.
Definition: chatchannel.h:190
std::vector< LiveChatMessage > mUserMessageBatch
A batch of messages to be sent together to the client instead of one at a time (for performance)...
Definition: chatchannel.h:207
uint64_t mUserMessageFlushInterval
The max amount of time between user message flushes to the main thread.
Definition: chatchannel.h:209
bool mBroadcasterLanguageMatch
Whether or not the local language matches the active native chat language.
Definition: chatchannel.h:243
TTV_ErrorCode SetBroadcasterLanguageChatEnabled(bool enabled, const SetBroadcasterLanguageChatCallback &callback)
LookupId mBitsConfigFetchToken
The cancellation token for fetching the BitsConfiguration.
Definition: chatchannel.h:235
std::shared_ptr< ChatConnection > mChatConnection
The active connection.
Definition: chatchannel.h:191
std::atomic< uint32_t > mNumOutstandingTasks
Definition: chatchannel.h:238
TTV_ErrorCode FetchChatProperties()
ChatUserInfo mSystemUserInfo
The display information for messages from JTV or TwitchNotify.
Definition: chatchannel.h:220
ChatChannel(const std::shared_ptr< User > &user, ChannelId channelId, std::shared_ptr< IChatChannelListener > chatCallbacks, std::shared_ptr< TaskRunner > taskRunner)
void SetClientChannelInfo(const ChatChannelInfo &channelInfo)
std::vector< std::string > mHosts
The hosts to use to connect to the channel.
Definition: chatchannel.h:187
std::shared_ptr< TaskRunner > mBackgroundTaskRunner
Definition: chatchannel.h:196
virtual void OnConnectionLost(ChatConnection *source, TTV_ErrorCode ec) override
Type
Definition: chattypes.h:375
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
void GenerateUserInfo(const std::string &username, const std::map< std::string, std::string > &messageTags, ChatUserInfo &userInfo)
Definition: chatchannel.h:53
ChatChannelRestrictions mServerChatRestrictions
The chat restrictions that are active for the channel on the chat thread.
Definition: chatchannel.h:226
ChatChannelState
Definition: chattypes.h:60
UserId GetChannelId() const
Definition: chatchannel.h:106
virtual void OnBadgesChanged(ChatConnection *source, const std::string &username, const std::string &badgesMessageTag) override
ChatChannelState mReportedClientState
The last reported state.
Definition: chatchannel.h:218
virtual void OnPrivateMessageReceived(ChatConnection *source, const std::string &username, const std::string &message, const std::map< std::string, std::string > &messageTags, bool action) override
void HandleRaidNotice(const std::string &message, const std::map< std::string, std::string > &messageTags)
std::shared_ptr< IChatChannelListener > mChatCallbacks
Client-configured callbacks for chat notifications for this channel.
Definition: chatchannel.h:185
void HandleConnectionIssue(bool recoverableError)
TTV_ErrorCode ProcessSetLocalLanguageRequest(const std::string &language)
virtual void OnUserStateChanged(ChatConnection *source, const std::map< std::string, std::string > &messageTags) override
void HandleMessageReceived(const std::string &username, const std::string &message, const std::map< std::string, std::string > &messageTags, const MessageInfo::Flags &flags)
virtual void OnNoticeReceived(ChatConnection *source, const std::string &id, const std::map< std::string, std::string > ¶ms) override
std::shared_ptr< BitsConfigRepository > mBitsConfigRepository
Definition: chatchannel.h:194
WaitForExpiry mFetchChatPropertiesTimer
The timer to use for fetching chat properties.
Definition: chatchannel.h:198
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)
TTV_ErrorCode ProcessClientChatMessage(const std::string &msg)
TTV_ErrorCode mConnectionError
Definition: chatchannel.h:215
std::weak_ptr< User > mUser
Definition: chatchannel.h:228
ConcurrentQueue< ThreadEvent > mToMainQ
The queue for messages from the chat thread to main thread.
Definition: chatchannel.h:204
std::shared_ptr< BitsConfiguration > mBitsConfiguration
Definition: chatchannel.h:230
std::string mLocalLanguage
The language used by the local user.
Definition: chatchannel.h:232
TTV_ErrorCode AttemptConnection()
Definition: chatchannel.h:45
TTV_ErrorCode ProcessChatPropertyFetchResult(TTV_ErrorCode ec, std::shared_ptr< ChatPropertiesTask::Result > result)
ChatMessagePacer mMessagePacer
Prevents the local user from sending too many messages too close together in time and getting banned...
Definition: chatchannel.h:211
void SetBitsConfigRepository(const std::shared_ptr< BitsConfigRepository > &repository)
Definition: chatchannel.h:70
virtual void OnCleared(ChatConnection *source, const std::string &username, const std::map< std::string, std::string > &messageTags) override
TTV_ErrorCode FlushClientEvents()
TTV_ErrorCode Disconnect()
void SetState(State::Enum state)
Definition: chatchannel.h:52
TTV_ErrorCode FetchBitsConfiguration()
virtual void OnHostTargetChanged(ChatConnection *source, const std::string &targetChannel, uint32_t numViewers) override
std::function< void(TTV_ErrorCode ec, UserList &&userList)> FetchUserListCallback
Definition: chatchannel.h:61
virtual void OnTemporaryBanChanged(ChatConnection *source, bool temporarilyBanned, uint32_t timeout) override
void SetMessageFlushInterval(uint64_t milliseconds)
Definition: chatchannel.h:108
uint32_t ChannelId
Definition: coretypes.h:23
TTV_ErrorCode OptInToBroadcasterLanguageChat(const std::string &language)
WaitForExpiry mNextUserMessageFlush
The next time in which to automatically flush all user messages to the main thread.
Definition: chatchannel.h:210
TokenizationOptions mTokenizationOptions
Marks what to tokenize in a message.
Definition: chatchannel.h:234
Definition: chattypes.h:126
Definition: coretypes.h:58
std::function< void(TTV_ErrorCode ec)> SetBroadcasterLanguageChatCallback
Definition: chatchannel.h:62
std::shared_ptr< ChannelRepository > mChannelRepository
Definition: chatchannel.h:192
Definition: chattypes.h:41
void SetTokenizationOptions(const TokenizationOptions &options)
Definition: chatchannel.h:68
bool mApplySlowMode
Definition: chatchannel.h:240
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)
virtual void OnConnected(ChatConnection *source) override
std::shared_ptr< TaskRunner > mTaskRunner
Definition: chatchannel.h:195
void SetChatObjectFactory(std::shared_ptr< IChatObjectFactory > factory)
virtual void OnChatRestrictionsChanged(ChatConnection *source, const ChatChannelRestrictions &restrictions) override
TTV_ErrorCode FetchUserList(const FetchUserListCallback &callback)
TTV_ErrorCode ProcessDisconnectRequest()