Twitch SDK (Internal)
chatsession.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_CHATSESSION_H
10 #define TTVSDK_CHATSESSION_H
11 
14 
16 
17 
18 namespace ttv
19 {
20  namespace chat
21  {
22  class ChatSession;
23  class ChatChannel;
24  }
25 }
26 
31 {
32 public:
33  ChatSession();
34  ~ChatSession();
35 
36  void SetWriter(std::shared_ptr<IChatWriteNetworkEvent> writer);
37 
40 
41  void Cap(const std::string& subCommand, const std::string& capabilities);
42  void Pass(const std::string& pass);
43  void User(const std::string& nick, const std::string& name);
44  void TwitchClient();
45  void Nick(const std::string& nick);
46  void Join(const std::string& channel, const std::string& key = std::string());
47  void Part(const std::string& channel, const std::string& msg = std::string());
48  void Kick(const std::string& channel, const std::string& user, const std::string& reason = std::string());
49  void Invite(const std::string& user, const std::string& channel);
50  void Topic(const std::string& channel, const std::string& topic = std::string());
51  void PrivMsg(const std::string& target, const std::string& msg);
52  void Action(const std::string& target, const std::string& msg);
53  void Notice(const std::string& target, const std::string& msg);
54  void CTCP(const std::string& target, const std::string& cmd, const std::string& msg = std::string());
55  void CTCPReply(const std::string& target, const std::string& cmd, const std::string& msg = std::string());
56  void CTCPPing(const std::string& target);
57  void Whois(const std::string& target);
58  void Mode(const std::string& target, const std::string& modes);
59  void UserHost(const std::string& user);
60  void Quit(const std::string& msg);
61  void Away(const std::string& msg);
62  void Raw(const std::string& text);
63  void Ping(const std::string& target);
64  void Pong(const std::string& target);
65  void List();
66 
67  const std::string& GetNick() const;
68  void SetNick(const std::string& nick);
69  bool IsMe(const std::string& nick);
70 
71  bool IsConnected() { return mConnected; }
72  uint64_t GetIdleTime();
73 
74  std::string GetChannelTypes();
75  void GetChannelUserModes(std::string* letters, std::string* symbols);
76 
77  bool HasServerCapability(const std::string& cap);
78  std::string GetServerCapability(const std::string& cap);
79 
80 
81  // IChatReceiveNetworkEvent implementation ///////////////////////
82  virtual void ReceiveEvent(const ChatNetworkEvent& evt);
83 
84 protected:
85  void ResetIdleCounter();
86 
87  // DispatchEvent - Send an event to the display handlers
88  void DispatchEvent(const ChatNetworkEvent& evt);
89 
90  // DoEvent - Send an outgoing event
91  void DoEvent(const ChatNetworkEvent& evt);
92 
94 
95  void OnConnect(const ChatNetworkEvent& evt);
96  void OnDisconnect(const ChatNetworkEvent& evt);
97 
98  void OnJoin(const ChatNetworkEvent& evt);
99  void OnPart(const ChatNetworkEvent& evt);
100  void OnKick(const ChatNetworkEvent& evt);
101  void OnNick(const ChatNetworkEvent& evt);
102  void OnQuit(const ChatNetworkEvent& evt);
103  void OnPing(const ChatNetworkEvent& evt);
104  void OnMode(const ChatNetworkEvent& evt);
105 
106  void OnCTCPPing(const ChatNetworkEvent& evt);
107  void OnCTCPVersion(const ChatNetworkEvent& evt);
108  void OnCTCPRplPing(const ChatNetworkEvent& evt);
109 
110  void OnRplNamReply(const ChatNetworkEvent& evt);
111  void OnRplWelcome(const ChatNetworkEvent& evt);
112  void OnRplProtoCtl(const ChatNetworkEvent& evt);
113  void OnRplListStart(const ChatNetworkEvent& evt);
114  void OnRplList(const ChatNetworkEvent& evt);
115 
116 private:
117  std::map<std::string, std::string> m_mapServerCaps;
118 
119  std::string mNick;
120  std::vector<IChatReceiveNetworkEvent*> mEventHandlers;
121 
122  std::shared_ptr<IChatWriteNetworkEvent> mWriter;
123 
124  uint64_t mLastActivity;
126 };
127 
128 #endif // TTVSDK_CHATSESSION_H
void OnKick(const ChatNetworkEvent &evt)
void OnPart(const ChatNetworkEvent &evt)
void OnJoin(const ChatNetworkEvent &evt)
void OnRplNamReply(const ChatNetworkEvent &evt)
void OnCTCPVersion(const ChatNetworkEvent &evt)
void SetWriter(std::shared_ptr< IChatWriteNetworkEvent > writer)
bool HasServerCapability(const std::string &cap)
bool IsMe(const std::string &nick)
std::vector< IChatReceiveNetworkEvent * > mEventHandlers
The child event handlers for incoming chat events.
Definition: chatsession.h:120
const std::string & GetNick() const
void OnConnect(const ChatNetworkEvent &evt)
Definition: chatsession.h:30
void OnDisconnect(const ChatNetworkEvent &evt)
uint64_t mLastActivity
Definition: chatsession.h:124
void CTCP(const std::string &target, const std::string &cmd, const std::string &msg=std::string())
void OnCTCPRplPing(const ChatNetworkEvent &evt)
void Action(const std::string &target, const std::string &msg)
Send an ACTION command to the server.
void OnNick(const ChatNetworkEvent &evt)
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
void OnCTCPPing(const ChatNetworkEvent &evt)
void PrivMsg(const std::string &target, const std::string &msg)
Send a PRIVMSG command to the server.
void Topic(const std::string &channel, const std::string &topic=std::string())
Send a TOPIC command to the server.
std::string GetChannelTypes()
std::string GetServerCapability(const std::string &cap)
void OnPing(const ChatNetworkEvent &evt)
void Kick(const std::string &channel, const std::string &user, const std::string &reason=std::string())
Send a KICK command to the server.
void Mode(const std::string &target, const std::string &modes)
void Whois(const std::string &target)
void OnRplProtoCtl(const ChatNetworkEvent &evt)
void Pong(const std::string &target)
Send a PONG command to the server.
void Ping(const std::string &target)
Send a PING command to the server.
void Pass(const std::string &pass)
Send a PASS command to the server.
void InitDefaultServerCapabilities()
void Away(const std::string &msg)
void RemoveEventHandler(IChatReceiveNetworkEvent *handler)
bool IsConnected()
Definition: chatsession.h:71
void Invite(const std::string &user, const std::string &channel)
Send an INVITE command to the server.
void Quit(const std::string &msg)
Send a QUIT command to the server.
void OnRplList(const ChatNetworkEvent &evt)
void CTCPReply(const std::string &target, const std::string &cmd, const std::string &msg=std::string())
void Nick(const std::string &nick)
Send a NICK command to the server.
void CTCPPing(const std::string &target)
std::shared_ptr< IChatWriteNetworkEvent > mWriter
The stream writer.
Definition: chatsession.h:122
void Cap(const std::string &subCommand, const std::string &capabilities)
Send a CAP REQ command to the server, capabilities is a space separated list.
void GetChannelUserModes(std::string *letters, std::string *symbols)
void DispatchEvent(const ChatNetworkEvent &evt)
void Join(const std::string &channel, const std::string &key=std::string())
Send a JOIN command to the server.
void OnRplWelcome(const ChatNetworkEvent &evt)
void Raw(const std::string &text)
void Part(const std::string &channel, const std::string &msg=std::string())
Send a PART command to the server.
void OnQuit(const ChatNetworkEvent &evt)
void User(const std::string &nick, const std::string &name)
Send a USER command to the server.
void AddEventHandler(IChatReceiveNetworkEvent *handler)
bool mConnected
Definition: chatsession.h:125
void SetNick(const std::string &nick)
Definition: chatnetworkevent.h:86
void DoEvent(const ChatNetworkEvent &evt)
std::string mNick
Definition: chatsession.h:119
void TwitchClient()
Send a TWITCHCLIENT command to the server.
Definition: chatnetworkevent.h:29
void OnMode(const ChatNetworkEvent &evt)
void UserHost(const std::string &user)
void OnRplListStart(const ChatNetworkEvent &evt)
std::map< std::string, std::string > m_mapServerCaps
Definition: chatsession.h:117
void Notice(const std::string &target, const std::string &msg)
Send a NOTICE command to the server.
virtual void ReceiveEvent(const ChatNetworkEvent &evt)
Accept an incoming event.