All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CommandServer.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "Networking.h"
7 #include "Commands.h"
8 #include "CommandTerminal.h"
9 #include "CommandProcessor.h"
10 #include "ITcpListener.h"
11 #include "ITcpClient.h"
12 #include "CommandCallback.h"
13 #include "TcpClientCallback.h"
14 
15 #include <vector>
16 
17 namespace Eegeo
18 {
19  namespace Debug
20  {
21  namespace DebugServer
22  {
24  protected Eegeo::NonCopyable
25  {
26  public:
28  Commands::CommandBuffer& commandBuffer,
29  Commands::CommandProcessor& commandProcessor,
30  Commands::CommandTerminal& commandTerminal);
31  ~CommandServer();
32 
33  void Write(const std::string& str) const;
34 
35  private:
36  void OnData(Networking::ITcpClient& client, char*& data, int& length);
37  void OnClientConnected(Networking::ITcpClient& client);
38  void OnClientDisconnected(Networking::ITcpClient& client);
39  void OnCommandCompleted();
40 
41  Networking::ITcpListener& m_listener;
42  Commands::CommandBuffer& m_commandBuffer;
43  Commands::CommandProcessor& m_commandProcessor;
44  Commands::CommandTerminal& m_commandTerminal;
45 
46  std::vector<Networking::ITcpClient*> m_clients;
47 
50 
51  TTcpClientDataCallback m_clientReadCallback;
52  TTcpClientCallback m_clientConnectionCallback;
53  TTcpClientCallback m_clientDisconnectionCallback;
54  Commands::TCommandCallback<CommandServer> m_commandCompletedCallback;
55  };
56  }
57  }
58 }