Twitch SDK (Internal)
chatraid.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 
18 
19 namespace ttv
20 {
21  class TaskRunner;
22  class ChannelRepository;
23 
24  namespace chat
25  {
26  class ChatRaid;
27  }
28 }
29 
30 
34 class ttv::chat::ChatRaid : public PubSubComponent<IChatRaidListener>, public IChatRaid
35 {
36 public:
37  using DisposerFunc = std::function<void()>;
38 
39 public:
40  ChatRaid(const std::shared_ptr<User>& user, ChannelId sourceChannelId);
41 
42  // Component Overrides
43  virtual void Update() override;
44  static std::string GetComponentName() { return "ttv::ChatRaid"; }
45  virtual std::string GetLoggerName() const override;
46 
47  // IChatRaid Implementation
48  virtual TTV_ErrorCode Dispose() override;
49  virtual TTV_ErrorCode Join(const std::string& raidId, const JoinCallback& callback) override;
50  virtual TTV_ErrorCode Leave(const std::string& raidId, const LeaveCallback& callback) override;
51  virtual TTV_ErrorCode Start(UserId targetUserId, const StartCallback& callback) override;
52  virtual TTV_ErrorCode Cancel(const CancelCallback& callback) override;
53 
54  void OnTopicSubscribeStateChanged(const std::string& topic, PubSubClient::SubscribeState::Enum state, TTV_ErrorCode ec) override;
55  void OnTopicMessageReceived(const std::string& topic, const json::Value& msg) override;
56 
57 private:
58  struct RaidEntry
59  {
61  {
62  }
63 
65  WaitForExpiry timer; // The timer that triggers the completion of the raid
66  };
67 
68  // Component overrides
69  virtual void CompleteShutdown() override;
70 
71  void HandleRaidStatus(RaidStatus& status, bool isCancel);
72 
73  std::map<std::string, RaidEntry> mRaids; // The currently active raids.
74  std::string mPubSubTopic;
76 };
uint32_t UserId
Definition: coretypes.h:22
void OnTopicMessageReceived(const std::string &topic, const json::Value &msg) override
virtual void CompleteShutdown() override
static std::string GetComponentName()
Definition: chatraid.h:44
Definition: chatraid.h:34
void OnTopicSubscribeStateChanged(const std::string &topic, PubSubClient::SubscribeState::Enum state, TTV_ErrorCode ec) override
Enum
Definition: pubsubclient.h:91
Definition: chattypes.h:853
std::function< void(TTV_ErrorCode ec)> StartCallback
Definition: ichatraid.h:33
RaidEntry()
Definition: chatraid.h:60
RaidStatus status
Definition: chatraid.h:64
Definition: chatraid.h:58
WaitForExpiry timer
Definition: chatraid.h:65
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
virtual TTV_ErrorCode Cancel(const CancelCallback &callback) override
virtual TTV_ErrorCode Dispose() override
Represents a JSON value.
Definition: value.h:114
Definition: timer.h:52
std::function< void(TTV_ErrorCode ec)> CancelCallback
Definition: ichatraid.h:34
std::function< void(TTV_ErrorCode ec)> LeaveCallback
Definition: ichatraid.h:32
std::function< void(TTV_ErrorCode ec)> JoinCallback
Definition: ichatraid.h:31
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
virtual std::string GetLoggerName() const override
void HandleRaidStatus(RaidStatus &status, bool isCancel)
virtual TTV_ErrorCode Leave(const std::string &raidId, const LeaveCallback &callback) override
std::function< void()> DisposerFunc
Definition: chatraid.h:37
Definition: ichatraid.h:28
virtual TTV_ErrorCode Join(const std::string &raidId, const JoinCallback &callback) override
virtual TTV_ErrorCode Start(UserId targetUserId, const StartCallback &callback) override
virtual void Update() override
ChatRaid(const std::shared_ptr< User > &user, ChannelId sourceChannelId)
std::map< std::string, RaidEntry > mRaids
Definition: chatraid.h:73
uint32_t ChannelId
Definition: coretypes.h:23
std::string mPubSubTopic
Definition: chatraid.h:74
ChannelId mSourceChannelId
Definition: chatraid.h:75
Definition: pubsubcomponent.h:21