Twitch SDK (Internal)
chatsockettransport.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 
12 #include "twitchsdk/core/socket.h"
13 
14 namespace ttv
15 {
16  namespace chat
17  {
18  class ChatSocketTransport;
19  }
20 }
21 
22 
27 {
28 public:
30  virtual ~ChatSocketTransport();
31 
32 // IChatTransport
33  virtual TTV_ErrorCode Connect(const std::string& uri); /* Connects to the transport. */
34  virtual TTV_ErrorCode Close(); /* Closes the transport. */
35  virtual bool IsOpen(); /* Whether or not the socket is open. */
36  virtual void SetReader(std::shared_ptr<IChatTransportReader> reader); /* Sets the reader. */
37  virtual TTV_ErrorCode ProcessIncomingEvent(bool& handled); /* Attempts to read a single message from the socket. */
38  virtual TTV_ErrorCode Write(const char* pData, size_t nSize); /* Writes the given data to the socket. */
39 
40  static TTV_ErrorCode CheckFactoryAvailability(const std::string& uri);
41 
42 private:
43  std::shared_ptr<IChatTransportReader> mReader;
44  std::shared_ptr<ISocket> mSocket;
45  std::shared_ptr<IWebSocket> mWebSocket;
46  std::vector<char> mBuffer;
47 };
std::shared_ptr< IChatTransportReader > mReader
The reader who will be notified when data is received.
Definition: chatsockettransport.h:43
Definition: chatsockettransport.h:26
virtual void SetReader(std::shared_ptr< IChatTransportReader > reader)
virtual TTV_ErrorCode ProcessIncomingEvent(bool &handled)
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
std::shared_ptr< IWebSocket > mWebSocket
The websocket for sending and receiving chat messages on.
Definition: chatsockettransport.h:45
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
virtual TTV_ErrorCode Connect(const std::string &uri)
std::shared_ptr< ISocket > mSocket
The raw socket for sending and receiving chat messages on.
Definition: chatsockettransport.h:44
virtual TTV_ErrorCode Write(const char *pData, size_t nSize)
virtual TTV_ErrorCode Close()
static TTV_ErrorCode CheckFactoryAvailability(const std::string &uri)
Definition: ichattransport.h:53
std::vector< char > mBuffer
A scratch buffer for reading data.
Definition: chatsockettransport.h:46