Twitch SDK (Internal)
chatgetuserthreadstask.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 
15 #include <map>
16 
17 namespace ttv
18 {
19  namespace chat
20  {
21  class ChatGetUserThreadsTask;
22  }
23 }
24 
26 {
27 public:
28  struct Result
29  {
30  std::vector<ThreadData> threadList;
31  int total; // The total number of threads for the user. If a threadId was used then this will be -1.
32  bool valid;
33  };
34 
35  typedef std::function<void(ChatGetUserThreadsTask* source, TTV_ErrorCode ec, std::shared_ptr<Result> result)> Callback;
36 
37 public:
38  ChatGetUserThreadsTask(const std::string& username, const std::string& authToken, const TokenizationOptions& tokenizationOptions, const std::shared_ptr<BitsConfiguration>& bitsConfiguration, Callback&& callback);
39 
40  void FetchByPage(uint32_t offset, uint32_t);
41  void FetchByUser(const std::string& otherUsername);
42  void FetchByThreadId(const std::string& threadId);
43 
44  // Stores the local user's names for properly parsing mentions
45  void SetLocalUserNames(const std::vector<std::string>& localUserNames) { mLocalUserNames = localUserNames; }
46 
47 protected:
48  virtual const char* GetTaskName() const { return "ChatGetUserThreadsTask"; }
49 
50  virtual void FillHttpRequestInfo(HttpRequestInfo& requestInfo);
51  virtual void ProcessResponse(const std::vector<char>& response);
52  virtual void ResponseCallback(uint statusCode, const std::vector<char>& response, void* userData);
53  virtual void OnComplete();
54 
55 private:
56  std::shared_ptr<BitsConfiguration> mBitsConfiguration;
57  std::shared_ptr<Result> mResult;
58  std::vector<std::string> mLocalUserNames;
60  std::string mUserName;
61  std::string mOtherUserName;
62  std::string mThreadId;
64  uint32_t mOffset;
65  uint32_t mLimit;
66 };
virtual void ProcessResponse(const std::vector< char > &response)
void FetchByThreadId(const std::string &threadId)
std::shared_ptr< BitsConfiguration > mBitsConfiguration
Definition: chatgetuserthreadstask.h:56
void SetLocalUserNames(const std::vector< std::string > &localUserNames)
Definition: chatgetuserthreadstask.h:45
uint32_t mOffset
Definition: chatgetuserthreadstask.h:64
std::string mUserName
Definition: chatgetuserthreadstask.h:60
virtual const char * GetTaskName() const
Definition: chatgetuserthreadstask.h:48
Definition: chatgetuserthreadstask.h:25
bool valid
Definition: chatgetuserthreadstask.h:32
ChatGetUserThreadsTask(const std::string &username, const std::string &authToken, const TokenizationOptions &tokenizationOptions, const std::shared_ptr< BitsConfiguration > &bitsConfiguration, Callback &&callback)
int total
Definition: chatgetuserthreadstask.h:31
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
Callback mCallback
Definition: chatgetuserthreadstask.h:59
TokenizationOptions mTokenizationOptions
Definition: chatgetuserthreadstask.h:63
Definition: chatgetuserthreadstask.h:28
Definition: chatapitask.h:26
std::vector< ThreadData > threadList
Definition: chatgetuserthreadstask.h:30
uint32_t mLimit
Definition: chatgetuserthreadstask.h:65
std::function< void(ChatGetUserThreadsTask *source, TTV_ErrorCode ec, std::shared_ptr< Result > result)> Callback
Definition: chatgetuserthreadstask.h:35
void FetchByPage(uint32_t offset, uint32_t)
virtual void ResponseCallback(uint statusCode, const std::vector< char > &response, void *userData)
unsigned int uint
Definition: coretypes.h:18
void FetchByUser(const std::string &otherUsername)
std::string mOtherUserName
Definition: chatgetuserthreadstask.h:61
virtual void FillHttpRequestInfo(HttpRequestInfo &requestInfo)
std::shared_ptr< Result > mResult
Definition: chatgetuserthreadstask.h:57
std::vector< std::string > mLocalUserNames
Definition: chatgetuserthreadstask.h:58
Definition: chattypes.h:41
std::string mThreadId
Definition: chatgetuserthreadstask.h:62
Definition: chatapitask.h:23