Twitch SDK (Internal)
chatgetthreadmessagestask.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 #ifndef TTVSDK_CHATGETTHREADMESSAGESTASK_H
10 #define TTVSDK_CHATGETTHREADMESSAGESTASK_H
11 
16 #include <map>
17 
18 namespace ttv
19 {
20  namespace chat
21  {
22  class ChatGetThreadMessagesTask;
23  }
24 }
25 
27 {
28 public:
29  struct Result
30  {
31  std::vector<WhisperMessage> messageList;
32  bool valid;
33  };
34 
35  typedef std::function<void(ChatGetThreadMessagesTask* source, TTV_ErrorCode ec, std::shared_ptr<Result> result)> Callback;
36 
37 public:
38  ChatGetThreadMessagesTask(const std::string& authToken, const std::string& threadId, const TokenizationOptions& tokenizationOptions, const std::shared_ptr<BitsConfiguration>& bitsConfiguration, Callback&& callback);
40 
41  void FetchDefault(); // Fetches the most recent N messages, where N is determined on the server.
42  void FetchRelative(MessageId beforeMessageId, uint32_t limit); // Fetches the last :limit messages before the given message id.
43  void SetLocalUserNames(const std::vector<std::string>& localUserNames) { mLocalUserNames = localUserNames; } // Stores the local user's names for properly parsing mentions
44 
45 protected:
46  virtual const char* GetTaskName() const { return "ChatGetThreadMessagesTask"; }
47 
48  virtual void FillHttpRequestInfo(HttpRequestInfo& requestInfo);
49  virtual void ResponseCallback(uint statusCode, const std::vector<char>& response, void* userData);
50  virtual void ProcessResponse(const std::vector<char>& response);
51  virtual void OnComplete();
52 
53 private:
54  std::shared_ptr<BitsConfiguration> mBitsConfiguration;
55  std::vector<std::string> mLocalUserNames;
56  std::shared_ptr<Result> mResult;
59  std::string mThreadId;
62 };
63 
64 #endif // TTVSDK_CHATGETTHREADMESSAGESTASK_H
void SetLocalUserNames(const std::vector< std::string > &localUserNames)
Definition: chatgetthreadmessagestask.h:43
MessageId mBeforeMessageId
Definition: chatgetthreadmessagestask.h:60
std::shared_ptr< Result > mResult
Definition: chatgetthreadmessagestask.h:56
bool valid
Definition: chatgetthreadmessagestask.h:32
uint32_t MessageId
Definition: chattypes.h:26
std::string mThreadId
Definition: chatgetthreadmessagestask.h:59
virtual void ResponseCallback(uint statusCode, const std::vector< char > &response, void *userData)
std::function< void(ChatGetThreadMessagesTask *source, TTV_ErrorCode ec, std::shared_ptr< Result > result)> Callback
Definition: chatgetthreadmessagestask.h:35
uint mLimit
Definition: chatgetthreadmessagestask.h:61
TokenizationOptions mTokenizationOptions
Definition: chatgetthreadmessagestask.h:58
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
std::vector< WhisperMessage > messageList
Definition: chatgetthreadmessagestask.h:31
void FetchRelative(MessageId beforeMessageId, uint32_t limit)
Definition: chatapitask.h:26
Definition: chatgetthreadmessagestask.h:29
virtual void FillHttpRequestInfo(HttpRequestInfo &requestInfo)
unsigned int uint
Definition: coretypes.h:18
virtual void ProcessResponse(const std::vector< char > &response)
std::vector< std::string > mLocalUserNames
Definition: chatgetthreadmessagestask.h:55
ChatGetThreadMessagesTask(const std::string &authToken, const std::string &threadId, const TokenizationOptions &tokenizationOptions, const std::shared_ptr< BitsConfiguration > &bitsConfiguration, Callback &&callback)
Callback mCallback
Definition: chatgetthreadmessagestask.h:57
virtual const char * GetTaskName() const
Definition: chatgetthreadmessagestask.h:46
Definition: chattypes.h:41
Definition: chatgetthreadmessagestask.h:26
std::shared_ptr< BitsConfiguration > mBitsConfiguration
Definition: chatgetthreadmessagestask.h:54
Definition: chatapitask.h:23