Twitch SDK (Internal)
cfsocket.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 
11 #include "twitchsdk/core/socket.h"
12 #include <CoreFoundation/CoreFoundation.h>
13 #include <CFNetwork/CFNetwork.h>
14 
15 namespace ttv
16 {
17  class CFSocket;
18  class RawCFSocketFactory;
19  class SecureCFSocketFactory;
20 }
21 
22 
23 class ttv::CFSocket : public ISocket
24 {
25 public:
26  CFSocket(const std::string& host, uint32_t port, bool useSsl);
27  virtual ~CFSocket();
28 
29  // ISocket Implementation
30  virtual TTV_ErrorCode Connect() override;
31  virtual TTV_ErrorCode Disconnect() override;
32  virtual TTV_ErrorCode Send(const uint8_t* buffer, size_t length, size_t& sent) override;
33  virtual TTV_ErrorCode Recv(uint8_t* buffer, size_t length, size_t& received) override;
34  virtual uint64_t TotalSent() override;
35  virtual uint64_t TotalReceived() override;
36  virtual bool Connected() override;
37 
38 private:
39  std::string mHostName;
40  uint32_t mPort;
41  uint64_t mTotalSent;
42  uint64_t mTotalReceived;
43  bool mUseSsl;
44  CFReadStreamRef mReadStream;
45  CFWriteStreamRef mWriteStream;
46 };
47 
48 
50 {
51 public:
52  virtual bool IsProtocolSupported(const std::string& protocol) override;
53  virtual TTV_ErrorCode CreateSocket(const std::string& uri, std::shared_ptr<ISocket>& result) override;
54 };
55 
56 
58 {
59 public:
60  virtual bool IsProtocolSupported(const std::string& protocol) override;
61  virtual TTV_ErrorCode CreateSocket(const std::string& uri, std::shared_ptr<ISocket>& result) override;
62 };
bool mUseSsl
Definition: cfsocket.h:43
uint64_t mTotalSent
Definition: cfsocket.h:41
uint64_t mTotalReceived
Definition: cfsocket.h:42
TTV_ErrorCode CreateSocket(const std::string &uri, std::shared_ptr< ISocket > &result)
CFReadStreamRef mReadStream
Definition: cfsocket.h:44
Definition: cfsocket.h:49
Definition: cfsocket.h:23
virtual ~CFSocket()
virtual TTV_ErrorCode Send(const uint8_t *buffer, size_t length, size_t &sent) override
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
virtual TTV_ErrorCode Disconnect() override
virtual TTV_ErrorCode Connect() override
Definition: cfsocket.h:57
virtual bool Connected() override
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
virtual TTV_ErrorCode Recv(uint8_t *buffer, size_t length, size_t &received) override
Definition: socket.h:181
Definition: socket.h:405
virtual uint64_t TotalReceived() override
uint32_t mPort
Definition: cfsocket.h:40
CFSocket(const std::string &host, uint32_t port, bool useSsl)
CFWriteStreamRef mWriteStream
Definition: cfsocket.h:45
std::string mHostName
Definition: cfsocket.h:39
virtual uint64_t TotalSent() override