Twitch SDK (Internal)
chatreader.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_CHATREADER_H
10 #define TTVSDK_CHATREADER_H
11 
14 
15 
16 namespace ttv
17 {
18  namespace chat
19  {
20  class ChatReader;
21  }
22 }
23 
24 
29 {
30 public:
31  ChatReader();
32  ~ChatReader();
33 
37  inline void SetNotifySink(IChatReceiveNetworkEvent* pNotify) { mNotify = pNotify; }
38 
39 
40 // IChatTransportReader implementation
41  virtual void OnConnect(TTV_ErrorCode err, const char* error);
42  virtual void OnError(TTV_ErrorCode err);
43  virtual void OnClose();
44  virtual void OnRead(const char* pData, size_t nSize);
45 
49  void OnLineRead(const char* line);
50 
51 private:
55  bool ParseEvent(ChatNetworkEvent& evt, const char* line);
56 
58  uint32_t mLineLength;
59  std::vector<char> mLineBuffer;
61 };
62 
63 #endif // TTVSDK_CHATREADER_H
virtual void OnRead(const char *pData, size_t nSize)
virtual void OnError(TTV_ErrorCode err)
static const uint32_t kMaxBufferSize
Definition: ichattransport.h:58
uint32_t mLineLength
The number of characters in the line buffer.
Definition: chatreader.h:58
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
bool ParseEvent(ChatNetworkEvent &evt, const char *line)
std::vector< char > mLineBuffer
The scratch buffer which may store a partial line between reads from the transport.
Definition: chatreader.h:59
IChatReceiveNetworkEvent * mNotify
The component to notify when a line is successfully read.
Definition: chatreader.h:57
virtual void OnClose()
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
char mParseBuffer[IChatTransport::kMaxBufferSize]
A scratch buffer for parsing lines.
Definition: chatreader.h:60
void OnLineRead(const char *line)
void SetNotifySink(IChatReceiveNetworkEvent *pNotify)
Definition: chatreader.h:37
Definition: ichattransport.h:24
Definition: chatreader.h:28
Definition: chatnetworkevent.h:86
Definition: chatnetworkevent.h:29
virtual void OnConnect(TTV_ErrorCode err, const char *error)