Twitch SDK (Internal)
chatlistener.h
Go to the documentation of this file.
1 /********************************************************************************************
2 * Twitch Broadcasting SDK
3 *
4 * This software is supplied under the terms of a license agreement with Twitch Interactive, Inc. and
5 * may not be copied or used except in accordance with the terms of that agreement
6 * Copyright (c) 2012-2016 Twitch Interactive, Inc.
7 *********************************************************************************************/
8 
9 #pragma once
10 
11 #include "twitchsdk/core/module.h"
13 #include <string>
14 #include <memory>
15 #include <map>
16 
17 namespace ttv
18 {
19  namespace chat
20  {
21  class IChatChannelListener;
22  class IChatAPIListener;
23  class IChatUserThreadsListener;
24  class IChatReplayListener;
25 
26  struct ChatChannelListenerProxy;
27  }
28 }
29 
30 
35 {
36 public:
37  virtual void ChatUserEmoticonSetsChanged(UserId userId, const std::vector<EmoticonSet>& emoticonSets) = 0;
38 };
39 
44 {
45 public:
46  virtual void ChatChannelStateChanged(UserId userId, ChannelId channelId, ChatChannelState state, TTV_ErrorCode ec) = 0;
47  virtual void ChatChannelInfoChanged(UserId userId, ChannelId channelId, const ChatChannelInfo& channelInfo) = 0;
48  virtual void ChatChannelRestrictionsChanged(UserId userId, ChannelId channelId, const ChatChannelRestrictions& restrictions) = 0;
49  virtual void ChatChannelLocalUserChanged(UserId userId, ChannelId channelId, const ChatUserInfo& userInfo) = 0;
50  virtual void ChatChannelMessagesReceived(UserId userId, ChannelId channelId, const std::vector<LiveChatMessage>& messageList) = 0;
51  virtual void ChatChannelSubscriptionNoticeReceived(UserId userId, ChannelId channelId, const SubscriptionNotice& notice) = 0;
52  virtual void ChatChannelFirstTimeChatterNoticeReceived(UserId userId, ChannelId channelId, const FirstTimeChatterNotice& notice) = 0;
53  virtual void ChatChannelRaidNoticeReceived(UserId userId, ChannelId channelId, const RaidNotice& notice) = 0;
54  virtual void ChatChannelUnraidNoticeReceived(UserId userId, ChannelId channelId, const UnraidNotice& notice) = 0;
58  virtual void ChatChannelMessagesCleared(UserId userId, ChannelId channelId) = 0;
62  virtual void ChatChannelUserMessagesCleared(UserId userId, ChannelId channelId, UserId clearUserId) = 0;
63  virtual void ChatChannelHostTargetChanged(UserId userId, ChannelId channelId, const std::string& targetChannelName, uint32_t numViewers) = 0;
64  virtual void ChatChannelNoticeReceived(UserId userId, ChannelId channelId, const std::string& noticeId, const std::map<std::string, std::string>& params) = 0;
65 };
66 
71 {
72 public:
73  virtual void ChatThreadRealtimeMessageReceived(UserId userId, const std::string& threadId, const WhisperMessage& messageList) = 0;
74  virtual void ChatThreadParticipantsUpdated(UserId userId, const std::string& threadId, const std::vector<ChatUserInfo>& participants) = 0;
75  virtual void ChatThreadUnreadMessageWindowChanged(UserId userId, const std::string& threadId, MessageId lastMessageId, MessageId lastReadMessageId) = 0;
76  virtual void ChatThreadMutedStatusChanged(UserId userId, const std::string& threadId, bool muted) = 0;
77  virtual void ChatThreadRemoved(UserId userId, const std::string& threadId) = 0;
78  virtual void ChatThreadGlobalUnreadCountsChanged(UserId userId, const UnreadThreadCounts& counts) = 0;
79 };
80 
81 
83 {
84 public:
88  virtual void ChatReplayStateChanged(UserId userId, const std::string& vodId, ChatReplayState state, TTV_ErrorCode ec) = 0;
92  virtual void ChatReplayCurrentTimeChanged(UserId userId, const std::string& vodId, Timestamp time) = 0;
97  virtual void ChatReplayMessagesReceived(UserId userId, const std::string& vodId, const std::vector<ReplayMessage>& messageList) = 0;
101  virtual void ChatReplayDeleteMessageComplete(UserId userId, const std::string& vodId, const std::string& messageId, TTV_ErrorCode ec) = 0;
102 };
103 
104 
106 {
107  using ChatChannelStateChangedCallback = std::function<void(UserId userId, ChannelId channelId, ChatChannelState state, TTV_ErrorCode ec)>;
108  using ChatChannelInfoChangedCallback = std::function<void(UserId userId, ChannelId channelId, const ChatChannelInfo& channelInfo)>;
109  using ChatChannelRestrictionsChangedCallback = std::function<void(UserId userId, ChannelId channelId, const ChatChannelRestrictions& restrictions)>;
110  using ChatChannelLocalUserChangedCallback = std::function<void(UserId userId, ChannelId channelId, const ChatUserInfo& userInfo)>;
111  using ChatChannelSubscriptionNoticeReceivedCallback = std::function<void(UserId userId, ChannelId channelId, const SubscriptionNotice& notice)>;
112  using ChatChannelFirstTimeChatterNoticeReceivedCallback = std::function<void(UserId userId, ChannelId channelId, const FirstTimeChatterNotice& notice)>;
113  using ChatChannelRaidNoticeReceivedCallback = std::function<void(UserId userId, ChannelId channelId, const RaidNotice& notice)>;
114  using ChatChannelUnraidNoticeReceivedCallback = std::function<void(UserId userId, ChannelId channelId, const UnraidNotice& notice)>;
115  using ChatChannelMessagesReceivedCallback = std::function<void(UserId userId, ChannelId channelId, const std::vector<LiveChatMessage>& messageList)>;
116  using ChatChannelMessagesClearedCallback = std::function<void(UserId userId, ChannelId channelId)>;
117  using ChatChannelUserMessagesClearedCallback = std::function<void(UserId userId, ChannelId channelId, UserId clearUserId)>;
118  using ChatChannelHostTargetChangedCallback = std::function<void(UserId userId, ChannelId channelId, const std::string& targetChannel, uint32_t numViewers)>;
119  using ChatChannelNoticeReceivedCallback = std::function<void(UserId userId, ChannelId channelId, const std::string& noticeId, const std::map<std::string, std::string>& params)>;
120  using ChatChannelSetBroadcasterLanguageChatEnabledCompleteCallback = std::function<void(UserId userId, ChannelId channelId, TTV_ErrorCode ec)>;
121 
122  // IChatChannelListener implementation
123  virtual void ChatChannelStateChanged(UserId userId, ChannelId channelId, ChatChannelState state, TTV_ErrorCode ec) override
124  {
125  if (chatChannelStateChangedCallback != nullptr)
126  {
127  chatChannelStateChangedCallback(userId, channelId, state, ec);
128  }
129  }
130 
131  virtual void ChatChannelInfoChanged(UserId userId, ChannelId channelId, const ChatChannelInfo& channelInfo) override
132  {
133  if (chatChannelInfoChangedCallback != nullptr)
134  {
135  chatChannelInfoChangedCallback(userId, channelId, channelInfo);
136  }
137  }
138 
139  virtual void ChatChannelRestrictionsChanged(UserId userId, ChannelId channelId, const ChatChannelRestrictions& restrictions) override
140  {
141  if (chatChannelRestrictionsChangedCallback != nullptr)
142  {
143  chatChannelRestrictionsChangedCallback(userId, channelId, restrictions);
144  }
145  }
146 
147  virtual void ChatChannelLocalUserChanged(UserId userId, ChannelId channelId, const ChatUserInfo& userInfo) override
148  {
149  if (chatChannelLocalUserChangedCallback != nullptr)
150  {
151  chatChannelLocalUserChangedCallback(userId, channelId, userInfo);
152  }
153  }
154 
155  virtual void ChatChannelSubscriptionNoticeReceived(UserId userId, ChannelId channelId, const SubscriptionNotice& notice) override
156  {
157  if (chatChannelSubscriptionNoticeReceivedCallback != nullptr)
158  {
159  chatChannelSubscriptionNoticeReceivedCallback(userId, channelId, notice);
160  }
161  }
162 
163  virtual void ChatChannelFirstTimeChatterNoticeReceived(UserId userId, ChannelId channelId, const FirstTimeChatterNotice& notice) override
164  {
165  if (chatChannelFirstTimeChatterNoticeReceivedCallback != nullptr)
166  {
167  chatChannelFirstTimeChatterNoticeReceivedCallback(userId, channelId, notice);
168  }
169  }
170 
171  virtual void ChatChannelRaidNoticeReceived(UserId userId, ChannelId channelId, const RaidNotice& notice) override
172  {
173  if (chatChannelRaidNoticeReceivedCallback != nullptr)
174  {
175  chatChannelRaidNoticeReceivedCallback(userId, channelId, notice);
176  }
177  }
178 
179  virtual void ChatChannelUnraidNoticeReceived(UserId userId, ChannelId channelId, const UnraidNotice& notice) override
180  {
181  if (chatChannelUnraidNoticeReceivedCallback != nullptr)
182  {
183  chatChannelUnraidNoticeReceivedCallback(userId, channelId, notice);
184  }
185  }
186 
187  virtual void ChatChannelMessagesReceived(UserId userId, ChannelId channelId, const std::vector<LiveChatMessage>& messageList) override
188  {
189  if (chatChannelMessagesReceivedCallback != nullptr)
190  {
191  chatChannelMessagesReceivedCallback(userId, channelId, messageList);
192  }
193  }
194 
195  virtual void ChatChannelMessagesCleared(UserId userId, ChannelId channelId) override
196  {
197  if (chatChannelMessagesClearedCallback != nullptr)
198  {
199  chatChannelMessagesClearedCallback(userId, channelId);
200  }
201  }
202 
203  virtual void ChatChannelUserMessagesCleared(UserId userId, ChannelId channelId, UserId clearUserId) override
204  {
205  if (chatChannelUserMessagesClearedCallback != nullptr)
206  {
207  chatChannelUserMessagesClearedCallback(userId, channelId, clearUserId);
208  }
209  }
210 
211  virtual void ChatChannelHostTargetChanged(UserId userId, ChannelId channelId, const std::string& targetChannel, uint32_t numViewers) override
212  {
213  if (chatChannelHostTargetChangedCallback != nullptr)
214  {
215  chatChannelHostTargetChangedCallback(userId, channelId, targetChannel, numViewers);
216  }
217  }
218 
219  virtual void ChatChannelNoticeReceived(UserId userId, ChannelId channelId, const std::string& noticeId, const std::map<std::string, std::string>& params) override
220  {
221  if (chatChannelNoticeReceivedCallback != nullptr)
222  {
223  chatChannelNoticeReceivedCallback(userId, channelId, noticeId, params);
224  }
225  }
226 
241 };
uint32_t UserId
Definition: coretypes.h:22
std::function< void(UserId userId, ChannelId channelId, const std::string &noticeId, const std::map< std::string, std::string > &params)> ChatChannelNoticeReceivedCallback
Definition: chatlistener.h:119
std::function< void(UserId userId, ChannelId channelId, const ChatChannelInfo &channelInfo)> ChatChannelInfoChangedCallback
Definition: chatlistener.h:108
ChatReplayState
Definition: chattypes.h:547
std::function< void(UserId userId, ChannelId channelId, const RaidNotice &notice)> ChatChannelRaidNoticeReceivedCallback
Definition: chatlistener.h:113
Definition: chatlistener.h:105
Definition: chattypes.h:161
ChatChannelMessagesClearedCallback chatChannelMessagesClearedCallback
Definition: chatlistener.h:236
Definition: chattypes.h:369
virtual void ChatChannelLocalUserChanged(UserId userId, ChannelId channelId, const ChatUserInfo &userInfo) override
Definition: chatlistener.h:147
virtual void ChatChannelSubscriptionNoticeReceived(UserId userId, ChannelId channelId, const SubscriptionNotice &notice) override
Definition: chatlistener.h:155
uint32_t MessageId
Definition: chattypes.h:26
Definition: chattypes.h:169
std::function< void(UserId userId, ChannelId channelId, ChatChannelState state, TTV_ErrorCode ec)> ChatChannelStateChangedCallback
Definition: chatlistener.h:107
std::function< void(UserId userId, ChannelId channelId, const ChatUserInfo &userInfo)> ChatChannelLocalUserChangedCallback
Definition: chatlistener.h:110
virtual void ChatChannelMessagesCleared(UserId userId, ChannelId channelId) override
Definition: chatlistener.h:195
uint32_t Timestamp
Definition: coretypes.h:27
std::function< void(UserId userId, ChannelId channelId, const std::vector< LiveChatMessage > &messageList)> ChatChannelMessagesReceivedCallback
Definition: chatlistener.h:115
std::function< void(UserId userId, ChannelId channelId, const ChatChannelRestrictions &restrictions)> ChatChannelRestrictionsChangedCallback
Definition: chatlistener.h:109
ChatChannelUserMessagesClearedCallback chatChannelUserMessagesClearedCallback
Definition: chatlistener.h:237
Definition: chatlistener.h:70
std::function< void(UserId userId, ChannelId channelId, const SubscriptionNotice &notice)> ChatChannelSubscriptionNoticeReceivedCallback
Definition: chatlistener.h:111
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
ChatChannelUnraidNoticeReceivedCallback chatChannelUnraidNoticeReceivedCallback
Definition: chatlistener.h:234
Definition: chatlistener.h:43
virtual void ChatChannelRestrictionsChanged(UserId userId, ChannelId channelId, const ChatChannelRestrictions &restrictions) override
Definition: chatlistener.h:139
Definition: module.h:153
Definition: chattypes.h:745
ChatChannelNoticeReceivedCallback chatChannelNoticeReceivedCallback
Definition: chatlistener.h:239
virtual void ChatChannelInfoChanged(UserId userId, ChannelId channelId, const ChatChannelInfo &channelInfo) override
Definition: chatlistener.h:131
ChatChannelStateChangedCallback chatChannelStateChangedCallback
Definition: chatlistener.h:227
virtual void ChatChannelMessagesReceived(UserId userId, ChannelId channelId, const std::vector< LiveChatMessage > &messageList) override
Definition: chatlistener.h:187
virtual void ChatUserEmoticonSetsChanged(UserId userId, const std::vector< EmoticonSet > &emoticonSets)=0
std::function< void(UserId userId, ChannelId channelId)> ChatChannelMessagesClearedCallback
Definition: chatlistener.h:116
virtual void ChatChannelRaidNoticeReceived(UserId userId, ChannelId channelId, const RaidNotice &notice) override
Definition: chatlistener.h:171
std::function< void(UserId userId, ChannelId channelId, const std::string &targetChannel, uint32_t numViewers)> ChatChannelHostTargetChangedCallback
Definition: chatlistener.h:118
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
virtual void ChatChannelStateChanged(UserId userId, ChannelId channelId, ChatChannelState state, TTV_ErrorCode ec) override
Definition: chatlistener.h:123
virtual void ChatChannelFirstTimeChatterNoticeReceived(UserId userId, ChannelId channelId, const FirstTimeChatterNotice &notice) override
Definition: chatlistener.h:163
ChatChannelState
Definition: chattypes.h:60
ChatChannelInfoChangedCallback chatChannelInfoChangedCallback
Definition: chatlistener.h:228
std::function< void(UserId userId, ChannelId channelId, UserId clearUserId)> ChatChannelUserMessagesClearedCallback
Definition: chatlistener.h:117
std::function< void(UserId userId, ChannelId channelId, const UnraidNotice &notice)> ChatChannelUnraidNoticeReceivedCallback
Definition: chatlistener.h:114
Definition: chatlistener.h:34
virtual void ChatChannelNoticeReceived(UserId userId, ChannelId channelId, const std::string &noticeId, const std::map< std::string, std::string > &params) override
Definition: chatlistener.h:219
ChatChannelLocalUserChangedCallback chatChannelLocalUserChangedCallback
Definition: chatlistener.h:230
virtual void ChatChannelUserMessagesCleared(UserId userId, ChannelId channelId, UserId clearUserId) override
Definition: chatlistener.h:203
ChatChannelRestrictionsChangedCallback chatChannelRestrictionsChangedCallback
Definition: chatlistener.h:229
Definition: chatlistener.h:82
ChatChannelHostTargetChangedCallback chatChannelHostTargetChangedCallback
Definition: chatlistener.h:238
virtual void ChatChannelHostTargetChanged(UserId userId, ChannelId channelId, const std::string &targetChannel, uint32_t numViewers) override
Definition: chatlistener.h:211
ChatChannelMessagesReceivedCallback chatChannelMessagesReceivedCallback
Definition: chatlistener.h:235
ChatChannelSetBroadcasterLanguageChatEnabledCompleteCallback chatChannelSetBroadcasterLanguageChatEnabledCompleteCallback
Definition: chatlistener.h:240
std::function< void(UserId userId, ChannelId channelId, TTV_ErrorCode ec)> ChatChannelSetBroadcasterLanguageChatEnabledCompleteCallback
Definition: chatlistener.h:120
uint32_t ChannelId
Definition: coretypes.h:23
Definition: chattypes.h:447
Definition: chattypes.h:126
Definition: chattypes.h:343
virtual void ChatChannelUnraidNoticeReceived(UserId userId, ChannelId channelId, const UnraidNotice &notice) override
Definition: chatlistener.h:179
Definition: chattypes.h:434
ChatChannelSubscriptionNoticeReceivedCallback chatChannelSubscriptionNoticeReceivedCallback
Definition: chatlistener.h:231
std::function< void(UserId userId, ChannelId channelId, const FirstTimeChatterNotice &notice)> ChatChannelFirstTimeChatterNoticeReceivedCallback
Definition: chatlistener.h:112
Definition: chattypes.h:423
ChatChannelRaidNoticeReceivedCallback chatChannelRaidNoticeReceivedCallback
Definition: chatlistener.h:233
ChatChannelFirstTimeChatterNoticeReceivedCallback chatChannelFirstTimeChatterNoticeReceivedCallback
Definition: chatlistener.h:232