All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TcpClient.h
1 // Copyright eeGeo Ltd (2012-2016), All Rights Reserved
2 
3 #pragma once
4 
5 #include "ITcpClient.h"
6 #include "ITcpSocket.h"
7 #include "TcpClientCallback.h"
8 #include "CallbackCollection.h"
9 
10 namespace Eegeo
11 {
12  namespace Networking
13  {
14  class TcpClient: public ITcpClient, protected Eegeo::NonCopyable
15  {
16  public:
17 
18  TcpClient(ITcpSocket* pClientSocket);
19  ~TcpClient();
20 
21  const ITcpSocket& GetSocket() const;
22 
23  bool Read();
24  void Write(const char* data, int length) const;
25  void Close();
26 
27  void AddReadCallback(ITcpClientDataCallback& readCallback);
28  void RemoveReadCallback(ITcpClientDataCallback& readCallback);
29  void AddCloseCallback(ITcpClientCallback& closeCallback);
30  void RemoveCloseCallback(ITcpClientCallback& closeCallback);
31 
32  private:
33  ITcpSocket* m_pClientSocket;
34 
37 
38  const static int MaxBuffer = 1024;
39  char m_buffer[MaxBuffer];
40  };
41  }
42 }