|
TOBI Interface A
0.1
|
00001 #ifndef CONTROL_CONNECTION_SERVER_2_IMPL_H 00002 #define CONTROL_CONNECTION_SERVER_2_IMPL_H 00003 00004 #include<list> 00005 00006 00007 #include "tia-private/newtia/network/tcp_server_socket.h" 00008 #include "tia-private/newtia/network_impl/boost_tcp_socket_impl.h" 00009 00010 #include "tia-private/newtia/server/control_connection_server_2.h" 00011 #include "tia-private/newtia/server/tia_server_state_server.h" 00012 00013 #include "tia-private/newtia/tia_control_command.h" 00014 #include "tia-private/newtia/tia_control_command_context.h" 00015 00016 #include "tia-private/newtia/messages/tia_control_message.h" 00017 #include "tia-private/newtia/messages/tia_control_message_builder.h" 00018 #include "tia-private/newtia/messages/tia_control_message_parser.h" 00019 00020 #include <boost/thread.hpp> 00021 #include <boost/asio/io_service.hpp> 00022 #include <boost/asio/deadline_timer.hpp> 00023 00024 namespace tia 00025 { 00026 00027 class ControlConnection2; 00028 00029 00030 class ControlConnectionServer2Impl : public ControlConnectionServer2, public NewConnectionListener 00031 { 00032 public: 00033 ControlConnectionServer2Impl(boost::shared_ptr<TCPServerSocket> server_socket, 00034 unsigned port, DataServer* data_server, 00035 TiAServerStateServer* server_state_server, 00036 HardwareInterface* hardware_interface); 00037 00038 virtual ~ControlConnectionServer2Impl (); 00039 virtual void newConnection (boost::shared_ptr<Socket> socket); 00040 00041 private: 00042 void checkConnections (boost::system::error_code error); 00043 00044 private: 00045 typedef std::map<std::string, TiAControlCommand*> CommandMap; 00046 00047 boost::shared_ptr<TCPServerSocket> server_socket_; 00048 unsigned int server_socket_port_; 00049 tia::DataServer* data_server_; 00050 TiAServerStateServer* server_state_server_; 00051 tia::HardwareInterface* hardware_interface_; 00052 00053 boost::mutex mutex_; 00054 00055 std::map<unsigned, tia::ControlConnection2*> connections_; 00056 00057 boost::asio::io_service io_service_; 00058 boost::asio::deadline_timer check_connections_timer_; 00059 boost::thread* io_thread_; 00060 }; 00061 } 00062 00063 #endif // CONTROL_CONNECTION_SERVER_2_IMPL_H