24 class ChatConnectionListenerProxy;
32 class IChatObjectFactory;
49 virtual void OnCleared(
ChatConnection* source,
const std::string& username,
const std::map<std::string, std::string>& messageTags) = 0;
50 virtual void OnPrivateMessageReceived(
ChatConnection* source,
const std::string& username,
const std::string& message,
const std::map<std::string, std::string>& messageTags,
bool action) = 0;
166 typedef std::function<void(ChatConnection* source, const std::string& username, const std::map<std::string, std::string>& messageTags)>
OnClearedFunc;
167 typedef std::function<void(ChatConnection* source, const std::string& username, const std::string& message, const std::map<std::string, std::string>& messageTags,
bool action)>
OnPrivateMessageReceivedFunc;
168 typedef std::function<void(ChatConnection* source, const std::string& message, const std::map<std::string, std::string>& messageTags)>
OnUserNoticeReceivedFunc;
169 typedef std::function<void(ChatConnection* source, const std::map<std::string, std::string>& messageTags)>
OnUserStateChangedFunc;
170 typedef std::function<void(ChatConnection* source, const std::string& username, const std::string& message, const std::map<std::string, std::string>& messageTags,
bool action)>
OnWhisperReceivedFunc;
171 typedef std::function<void(ChatConnection* source, const std::string& receivingUserName, const std::string& message, const std::map<std::string, std::string>& messageTags,
bool action)>
OnWhisperSentFunc;
175 typedef std::function<void(ChatConnection* source, const std::string& username, const std::vector<EmoticonSetId>& emoticonSets)>
OnEmoticonSetsChangedFunc;
176 typedef std::function<void(ChatConnection* source, const std::string& username, const std::string& badgesMessageTag)>
OnBadgesChangedFunc;
177 typedef std::function<void(ChatConnection* source, const std::string& targetChannel, uint32_t numViewers)>
OnHostTargetChangedFunc;
178 typedef std::function<void(ChatConnection* source, const std::string& id, const std::map<std::string, std::string>& params)>
OnNoticeReceivedFunc;
179 typedef std::function<void(ChatConnection* source, const std::string& blockUserName, bool ignore)>
OnIgnoreChangedFunc;
184 if (mOnConnectedFunc !=
nullptr)
186 mOnConnectedFunc(source);
192 if (mOnConnectionFailedFunc !=
nullptr)
194 mOnConnectionFailedFunc(source, ec);
200 if (mOnConnectionLostFunc !=
nullptr)
202 mOnConnectionLostFunc(source, ec);
206 virtual void OnCleared(
ChatConnection* source,
const std::string& username,
const std::map<std::string, std::string>& messageTags)
override 208 if (mOnClearedFunc !=
nullptr)
210 mOnClearedFunc(source, username, messageTags);
216 if (mOnPrivateMessageReceivedFunc !=
nullptr)
218 mOnPrivateMessageReceivedFunc(source, username, message, messageTags, action);
224 if (mOnUserNoticeReceivedFunc !=
nullptr)
226 mOnUserNoticeReceivedFunc(source, message, messageTags);
232 if (mOnUserStateChangedFunc !=
nullptr)
234 mOnUserStateChangedFunc(source, messageTags);
240 if (mOnChatRestrictionsChangedFunc !=
nullptr)
242 mOnChatRestrictionsChangedFunc(source, restrictions);
248 if (mOnPermanentBanChangedFunc !=
nullptr)
250 mOnPermanentBanChangedFunc(source, banned);
256 if (mOnTemporaryBanChangedFunc !=
nullptr)
258 mOnTemporaryBanChangedFunc(source, temporarilyBanned, timeout);
264 if (mOnBadgesChangedFunc !=
nullptr)
266 mOnBadgesChangedFunc(source, username, badgesMessageTag);
272 if (mOnHostTargetChangedFunc !=
nullptr)
274 mOnHostTargetChangedFunc(source, targetChannel, numViewers);
280 if (mOnNoticeReceivedFunc !=
nullptr)
282 mOnNoticeReceivedFunc(source,
id, params);
288 if (mOnIgnoreChangedFunc !=
nullptr)
290 mOnIgnoreChangedFunc(source, blockUserName, ignore);
virtual void OnConnectionLost(ChatConnection *source, TTV_ErrorCode ec) override
Definition: chatconnection.h:198
void SetChannelName(const std::string &channelName)
std::function< void(ChatConnection *source, TTV_ErrorCode ec)> OnConnectionFailedFunc
Definition: chatconnection.h:164
std::string CreateAnonymousUserName()
bool mAnonymous
Whether or not connecting anonymously to the channel.
Definition: chatconnection.h:151
ConnectionState mConnectionState
Definition: chatconnection.h:142
virtual void OnNoticeReceived(ChatConnection *source, const std::string &id, const std::map< std::string, std::string > ¶ms) override
Definition: chatconnection.h:278
ChatConnection(ChannelId channelId, const std::shared_ptr< User > &user)
virtual void OnTemporaryBanChanged(ChatConnection *source, bool temporarilyBanned, uint32_t timeout) override
Definition: chatconnection.h:254
virtual void OnConnectionFailed(ChatConnection *source, TTV_ErrorCode ec)=0
virtual void OnConnectionLost(ChatConnection *source, TTV_ErrorCode ec)=0
std::function< void(ChatConnection *source, bool banned)> OnPermanentBanChangedFunc
Definition: chatconnection.h:173
std::function< void(ChatConnection *source)> OnConnectedFunc
Definition: chatconnection.h:163
std::string mUserName
The cached username.
Definition: chatconnection.h:140
virtual void OnConnectionFailed(ChatConnection *source, TTV_ErrorCode ec) override
Definition: chatconnection.h:190
std::function< void(ChatConnection *source, const std::string &username, const std::string &message, const std::map< std::string, std::string > &messageTags, bool action)> OnWhisperReceivedFunc
Definition: chatconnection.h:170
Definition: chatconnection.h:70
std::string mIrcChannelName
Definition: chatconnection.h:139
std::function< void(ChatConnection *source, const std::string &blockUserName, bool ignore)> OnIgnoreChangedFunc
Definition: chatconnection.h:179
virtual void OnPermanentBanChanged(ChatConnection *source, bool banned)=0
Definition: chatconnection.h:65
ConnectionState
Definition: chatconnection.h:63
virtual void OnIgnoreChanged(ChatConnection *source, const std::string &blockUserName, bool ignore) override
Definition: chatconnection.h:286
Definition: chatconnection.h:40
virtual void OnPrivateMessageReceived(ChatConnection *source, const std::string &username, const std::string &message, const std::map< std::string, std::string > &messageTags, bool action) override
Definition: chatconnection.h:214
Definition: chattypes.h:169
OnTemporaryBanChangedFunc mOnTemporaryBanChangedFunc
Definition: chatconnection.h:306
OnNoticeReceivedFunc mOnNoticeReceivedFunc
Definition: chatconnection.h:309
Listener * mListener
Definition: chatconnection.h:143
virtual void OnNoticeReceived(ChatConnection *source, const std::string &id, const std::map< std::string, std::string > ¶ms)=0
TTV_ErrorCode SendChatMessage(const std::string &message, const ChatUserInfo &localUserInfo)
Definition: chatconnection.h:43
std::function< void(ChatConnection *source, const std::string &receivingUserName, const std::string &message, const std::map< std::string, std::string > &messageTags, bool action)> OnWhisperSentFunc
Definition: chatconnection.h:171
OnHostTargetChangedFunc mOnHostTargetChangedFunc
Definition: chatconnection.h:308
void SetListener(Listener *listener)
Definition: chatconnection.h:79
OnWhisperReceivedFunc mOnWhisperReceivedFunc
Definition: chatconnection.h:302
std::function< void(ChatConnection *source, const std::string &targetChannel, uint32_t numViewers)> OnHostTargetChangedFunc
Definition: chatconnection.h:177
void HandleHostTargetMessage(const ChatNetworkEvent &evt)
std::function< void(ChatConnection *source, const std::string &username, const std::string &badgesMessageTag)> OnBadgesChangedFunc
Definition: chatconnection.h:176
void SetState(ConnectionState state)
TTV_ErrorCode Connect(const std::string &uri)
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
OnWhisperSentFunc mOnWhisperSentFunc
Definition: chatconnection.h:303
std::function< void(ChatConnection *source, bool temporarilyBanned, uint32_t timeout)> OnTemporaryBanChangedFunc
Definition: chatconnection.h:174
virtual void OnUserStateChanged(ChatConnection *source, const std::map< std::string, std::string > &messageTags)=0
void HandleUserNotice(const ChatNetworkEvent &evt)
std::shared_ptr< ChatWriter > mWriter
The socket writer.
Definition: chatconnection.h:130
OnUserNoticeReceivedFunc mOnUserNoticeReceivedFunc
Definition: chatconnection.h:300
void HandleMessageTags(const ChatNetworkEvent &evt)
void HandleClearChatMessage(const ChatNetworkEvent &evt)
std::shared_ptr< IChatTransport > mTransport
The transport for sending and receiving chat messages.
Definition: chatconnection.h:134
Definition: chatconnection.h:67
std::function< void(ChatConnection *source, const std::string &username, const std::string &message, const std::map< std::string, std::string > &messageTags, bool action)> OnPrivateMessageReceivedFunc
Definition: chatconnection.h:167
std::function< void(ChatConnection *source, const std::string &username, const std::map< std::string, std::string > &messageTags)> OnClearedFunc
Definition: chatconnection.h:166
virtual void OnUserStateChanged(ChatConnection *source, const std::map< std::string, std::string > &messageTags) override
Definition: chatconnection.h:230
Definition: chatconnection.h:72
Definition: chatconnection.h:69
virtual void OnChatRestrictionsChanged(ChatConnection *source, const ChatChannelRestrictions &restrictions)=0
Definition: chatconnection.h:66
std::function< void(ChatConnection *source, const std::string &id, const std::map< std::string, std::string > ¶ms)> OnNoticeReceivedFunc
Definition: chatconnection.h:178
void HandlePrivateMessage(const ChatNetworkEvent &evt)
Definition: chatconnection.h:68
std::shared_ptr< IChatObjectFactory > mChatObjectFactory
The internal chat object factory.
Definition: chatconnection.h:132
OnPrivateMessageReceivedFunc mOnPrivateMessageReceivedFunc
Definition: chatconnection.h:299
virtual void OnCleared(ChatConnection *source, const std::string &username, const std::map< std::string, std::string > &messageTags)=0
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
OnBadgesChangedFunc mOnBadgesChangedFunc
Definition: chatconnection.h:307
OnChatRestrictionsChangedFunc mOnChatRestrictionsChangedFunc
Definition: chatconnection.h:304
virtual void OnPermanentBanChanged(ChatConnection *source, bool banned) override
Definition: chatconnection.h:246
virtual void OnTemporaryBanChanged(ChatConnection *source, bool temporarilyBanned, uint32_t timeout)=0
bool mFireConnectionErrorEvents
Whether or not to fire a connection error event.
Definition: chatconnection.h:153
OnUserStateChangedFunc mOnUserStateChangedFunc
Definition: chatconnection.h:301
virtual ~ChatConnection()
bool mDisconnectionRequested
Whether or not expecting a disconnect.
Definition: chatconnection.h:152
TTV_ErrorCode Disconnect()
std::string GetLocalUserName() const
Definition: chatconnection.h:98
std::shared_ptr< ChatReader > mReader
The socket reader.
Definition: chatconnection.h:129
Definition: chatconnection.h:160
OnClearedFunc mOnClearedFunc
Definition: chatconnection.h:298
OnConnectionLostFunc mOnConnectionLostFunc
Definition: chatconnection.h:297
virtual void OnConnected(ChatConnection *source) override
Definition: chatconnection.h:182
OnIgnoreChangedFunc mOnIgnoreChangedFunc
Definition: chatconnection.h:310
WaitForEventWithTimeout mWelcomeMessageTimeout
Definition: chatconnection.h:136
std::shared_ptr< User > mUser
Definition: chatconnection.h:146
std::function< void(ChatConnection *source, const std::map< std::string, std::string > &messageTags)> OnUserStateChangedFunc
Definition: chatconnection.h:169
OnPermanentBanChangedFunc mOnPermanentBanChangedFunc
Definition: chatconnection.h:305
virtual void ReceiveEvent(const ChatNetworkEvent &evt)
WaitForEventWithTimeout mJoinAttemptTimeout
Definition: chatconnection.h:137
virtual void OnIgnoreChanged(ChatConnection *source, const std::string &blockUserName, bool ignore)=0
Definition: chatconnection.h:71
virtual void OnBadgesChanged(ChatConnection *source, const std::string &username, const std::string &badgesMessageTag) override
Definition: chatconnection.h:262
void HandleCapMessage(const ChatNetworkEvent &evt)
void HandleRoomState(const ChatNetworkEvent &evt)
void HandleNotice(const ChatNetworkEvent &evt)
OnConnectionFailedFunc mOnConnectionFailedFunc
Definition: chatconnection.h:296
std::function< void(ChatConnection *source, const std::string &message, const std::map< std::string, std::string > &messageTags)> OnUserNoticeReceivedFunc
Definition: chatconnection.h:168
uint32_t ChannelId
Definition: coretypes.h:23
virtual void OnUserNoticeReceived(ChatConnection *source, const std::string &message, const std::map< std::string, std::string > &messageTags)=0
virtual void OnChatRestrictionsChanged(ChatConnection *source, const ChatChannelRestrictions &restrictions) override
Definition: chatconnection.h:238
virtual void OnHostTargetChanged(ChatConnection *source, const std::string &targetChannel, uint32_t numViewers) override
Definition: chatconnection.h:270
virtual void OnUserNoticeReceived(ChatConnection *source, const std::string &message, const std::map< std::string, std::string > &messageTags) override
Definition: chatconnection.h:222
Definition: chattypes.h:126
std::shared_ptr< ChatSession > mSession
The message interpreter.
Definition: chatconnection.h:131
virtual void OnBadgesChanged(ChatConnection *source, const std::string &username, const std::string &badgesMessageTag)=0
void HandleUserState(const ChatNetworkEvent &evt)
TTV_ErrorCode mConnectionError
Definition: chatconnection.h:144
std::function< void(ChatConnection *source, TTV_ErrorCode ec)> OnConnectionLostFunc
Definition: chatconnection.h:165
ChatChannelRestrictions mChatRestrictions
Stores the state of chat restrictions received by ROOMSTATE.
Definition: chatconnection.h:149
virtual void OnPrivateMessageReceived(ChatConnection *source, const std::string &username, const std::string &message, const std::map< std::string, std::string > &messageTags, bool action)=0
Definition: chatnetworkevent.h:86
void SetChatObjectFactory(std::shared_ptr< IChatObjectFactory > factory)
virtual void OnHostTargetChanged(ChatConnection *source, const std::string &targetChannel, uint32_t numViewers)=0
ChannelId mChannelId
Definition: chatconnection.h:148
Definition: chatnetworkevent.h:29
OnConnectedFunc mOnConnectedFunc
Definition: chatconnection.h:295
std::function< void(ChatConnection *source, ChatChannelRestrictions)> OnChatRestrictionsChangedFunc
Definition: chatconnection.h:172
static TTV_ErrorCode CheckFactoryAvailability(const std::string &uri)
std::function< void(ChatConnection *source, const std::string &username, const std::vector< EmoticonSetId > &emoticonSets)> OnEmoticonSetsChangedFunc
Definition: chatconnection.h:175
virtual void OnCleared(ChatConnection *source, const std::string &username, const std::map< std::string, std::string > &messageTags) override
Definition: chatconnection.h:206
virtual void OnConnected(ChatConnection *source)=0