Twitch SDK (Internal)
standardopensslsocket.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 
13 #include <memory>
14 
15 namespace ttv
16 {
17  class OpenSslSocket;
18  class OpenSslSocketFactory;
19 }
20 
21 
26 {
27 public:
28  OpenSslSocket();
30 
31  TTV_ErrorCode Initialize(const std::string& host, const std::string& port);
32 
33  // ISocket Implementation
34  virtual TTV_ErrorCode Connect();
35  virtual TTV_ErrorCode Disconnect();
36  virtual TTV_ErrorCode Send(const uint8_t* buffer, size_t length, size_t& sent);
37  virtual TTV_ErrorCode Recv(uint8_t* buffer, size_t length, size_t& received);
38  virtual uint64_t TotalSent();
39  virtual uint64_t TotalReceived();
40  virtual bool Connected();
41 
42  TTV_ErrorCode SetCertificateData(const std::string& data);
43 
46 
51  static void SetTrustedHosts(const std::vector<std::string>& trustedHosts);
52 
53 private:
54  class SocketData;
55 
61 
62  static std::vector<std::string> sTrustedHosts;
63  std::string mHost;
64  std::string mPort;
65  std::shared_ptr<ISocket> mBaseSocket;
66  std::unique_ptr<SocketData> mSocketData;
67  std::string mCertificateData;
68 
69  bool mConnected;
70 };
71 
72 
74 {
75 public:
76  virtual ~OpenSslSocketFactory();
77  virtual bool IsProtocolSupported(const std::string& protocol);
78  virtual TTV_ErrorCode CreateSocket(const std::string& uri, std::shared_ptr<ISocket>& result);
79 };
std::string mCertificateData
Definition: standardopensslsocket.h:67
TTV_ErrorCode CreateSocket(const std::string &uri, std::shared_ptr< ISocket > &result)
static std::vector< std::string > sTrustedHosts
Definition: standardopensslsocket.h:62
TTV_ErrorCode Initialize(const std::string &host, const std::string &port)
virtual bool Connected()
virtual TTV_ErrorCode Send(const uint8_t *buffer, size_t length, size_t &sent)
virtual uint64_t TotalReceived()
TTV_ErrorCode FlushIncoming()
TTV_ErrorCode Handshake()
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
std::shared_ptr< ISocket > mBaseSocket
Definition: standardopensslsocket.h:65
static TTV_ErrorCode ShutdownOpenSslSockets()
TTV_ErrorCode FlushOutgoing()
TTV_ErrorCode SetCertificateData(const std::string &data)
TTV_ErrorCode PrepareConnection()
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
virtual TTV_ErrorCode Disconnect()
Definition: socket.h:181
std::unique_ptr< SocketData > mSocketData
Definition: standardopensslsocket.h:66
Definition: standardopensslsocket.h:25
Definition: socket.h:405
static void SetTrustedHosts(const std::vector< std::string > &trustedHosts)
bool mConnected
Definition: standardopensslsocket.h:69
virtual TTV_ErrorCode Connect()
virtual uint64_t TotalSent()
Definition: standardopensslsocket.h:73
virtual TTV_ErrorCode Recv(uint8_t *buffer, size_t length, size_t &received)
std::string mPort
Definition: standardopensslsocket.h:64
std::string mHost
Definition: standardopensslsocket.h:63
static TTV_ErrorCode InitializeOpenSslSockets()
TTV_ErrorCode Flush()