Twitch SDK (Internal)
useremoticonsets.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 
14 
15 namespace ttv
16 {
17  class User;
18 
19  namespace chat
20  {
21  class UserEmoticonSets;
22  class UserEmoticonSetsListener;
23  class UserEmoticonSetsListenerProxy;
24  }
25 }
26 
30 class ttv::chat::UserEmoticonSets : public PubSubComponent<UserEmoticonSetsListener>
31 {
32 public:
33  using FetchEmoticonSetsCallback = std::function<void(TTV_ErrorCode ec, const std::vector<EmoticonSet>& result)>;
34 
35  UserEmoticonSets(const std::shared_ptr<User>& user, const TokenizationOptions& options);
36  virtual ~UserEmoticonSets();
37 
38  // Component overrides
39  virtual TTV_ErrorCode Initialize() override;
40  virtual void Update() override;
41  virtual TTV_ErrorCode Shutdown() override;
42 
43  virtual std::string GetLoggerName() const override;
44  static std::string GetComponentName() { return "ttv::chat::UserEmoticonSets"; }
45 
49  TTV_ErrorCode GetUserEmoticonSets(std::vector<EmoticonSet>& sets);
50 
57  TTV_ErrorCode FetchUserEmoticonSets(bool forceFetch, const FetchEmoticonSetsCallback& callback);
58 
63 
64  void OnTopicSubscribeStateChanged(const std::string& topic, PubSubClient::SubscribeState::Enum state, TTV_ErrorCode ec) override;
65 
69  void OnTopicMessageReceived(const std::string& topic, const ttv::json::Value& jVal) override;
70 
71 private:
73  std::vector<EmoticonSet> mUserEmoticonSets;
74 
75  std::string mPubSubTopic;
76 
79 
81 };
82 
83 
88 {
89 public:
90  virtual void OnUserEmoticonSetsChanged(UserId userId, const std::vector<EmoticonSet>& sets) = 0;
91 };
92 
93 
98 {
99 public:
100  typedef std::function<void(UserId userId, const std::vector<EmoticonSet>& emoticonSet) > UserEmoticonSetsChangedFunc;
101 
102 public:
103  virtual void OnUserEmoticonSetsChanged(UserId userId, const std::vector<EmoticonSet>& emoticonSets) override
104  {
105  if (mUserEmoticonSetsChangedFunc != nullptr)
106  {
107  mUserEmoticonSetsChangedFunc(userId, emoticonSets);
108  }
109  }
110 
111 public:
113 };
std::function< void(TTV_ErrorCode ec, const std::vector< EmoticonSet > &result)> FetchEmoticonSetsCallback
Definition: useremoticonsets.h:33
uint32_t UserId
Definition: coretypes.h:22
Definition: timer.h:134
std::string mPubSubTopic
Definition: useremoticonsets.h:75
std::vector< EmoticonSet > mUserEmoticonSets
Definition: useremoticonsets.h:73
virtual std::string GetLoggerName() const override
UserEmoticonSets(const std::shared_ptr< User > &user, const TokenizationOptions &options)
Definition: useremoticonsets.h:87
void OnTopicSubscribeStateChanged(const std::string &topic, PubSubClient::SubscribeState::Enum state, TTV_ErrorCode ec) override
Enum
Definition: pubsubclient.h:91
bool mEmoticonFetchInFlight
Definition: useremoticonsets.h:80
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
CallbackQueue< FetchEmoticonSetsCallback > mFetchUserEmoticonSetsCallbacks
Definition: useremoticonsets.h:72
UserEmoticonSetsChangedFunc mUserEmoticonSetsChangedFunc
Definition: useremoticonsets.h:112
virtual TTV_ErrorCode Shutdown() override
RetryTimer mFetchRetryTimer
Definition: useremoticonsets.h:77
Represents a JSON value.
Definition: value.h:114
std::function< void(UserId userId, const std::vector< EmoticonSet > &emoticonSet) > UserEmoticonSetsChangedFunc
Definition: useremoticonsets.h:100
TokenizationOptions GetTokenizationOptions() const
Definition: useremoticonsets.h:62
virtual TTV_ErrorCode Initialize() override
Definition: useremoticonsets.h:97
TTV_ErrorCode FetchUserEmoticonSets(bool forceFetch, const FetchEmoticonSetsCallback &callback)
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
TTV_ErrorCode GetUserEmoticonSets(std::vector< EmoticonSet > &sets)
virtual void OnUserEmoticonSetsChanged(UserId userId, const std::vector< EmoticonSet > &emoticonSets) override
Definition: useremoticonsets.h:103
Definition: useremoticonsets.h:30
virtual void Update() override
TokenizationOptions mTokenizationOptions
Definition: useremoticonsets.h:78
static std::string GetComponentName()
Definition: useremoticonsets.h:44
void OnTopicMessageReceived(const std::string &topic, const ttv::json::Value &jVal) override
Definition: chattypes.h:41
Definition: pubsubcomponent.h:21