Rev 1959 | Rev 1963 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1959 | Rev 1962 | ||
|---|---|---|---|
| Line 26... | Line 26... | ||
| 26 | 26 | ||
| 27 | #include <boost/signals2.hpp> |
27 | #include <boost/signals2.hpp> |
| 28 | #include <boost/shared_ptr.hpp> |
28 | #include <boost/shared_ptr.hpp> |
| 29 | 29 | ||
| 30 | #include "common/IoService.h" |
30 | #include "common/IoService.h" |
| 31 | #include "logging/Logger.h" |
- | |
| 32 | 31 | ||
| 33 | #include "types.h" |
32 | #include "types.h" |
| 34 | #include "Client.h" |
33 | #include "Client.h" |
| 35 | #include "TcpClient.h" |
34 | #include "TcpClient.h" |
| 36 | #include "UdpClient.h" |
35 | #include "UdpClient.h" |
| 37 | #include "SerialClient.h" |
36 | #include "SerialClient.h" |
| - | 37 | #include "TcpServer.h" |
|
| - | 38 | ||
| 38 | 39 | ||
| 39 | namespace atom { |
40 | namespace atom { |
| 40 | namespace net { |
41 | namespace net { |
| 41 | 42 | ||
| 42 | class Manager : public common::IoService |
43 | class Manager : public common::IoService |
| 43 | { |
44 | { |
| 44 | public: |
45 | public: |
| 45 | typedef boost::shared_ptr<Manager> Pointer; |
46 | typedef boost::shared_ptr<Manager> Pointer; |
| 46 | 47 | ||
| 47 | typedef boost::signals2::signal<void(SocketId, SocketId, ClientState)> SignalOnNewState; |
48 | typedef boost::signals2::signal<void(SocketId, SocketId, ClientState)> SignalOnNewState; |
| 48 | typedef boost::signals2::signal<void(SocketId, SocketId, common::Byteset)> SignalOnNewData; |
49 | typedef boost::signals2::signal<void(SocketId, SocketId, common::Byteset)> SignalOnNewData; |
| 49 | 50 | ||
| 50 | virtual ~Manager(); |
51 | virtual ~Manager(); |
| 51 | 52 | ||
| Line 64... | Line 65... | ||
| 64 | void SendToAll(SocketId server_id, common::Byteset data); |
65 | void SendToAll(SocketId server_id, common::Byteset data); |
| 65 | void SendTo(SocketId client_id, common::Byteset data); |
66 | void SendTo(SocketId client_id, common::Byteset data); |
| 66 | 67 | ||
| 67 | private: |
68 | private: |
| 68 | typedef std::map<SocketId, Client::Pointer> ClientList; |
69 | typedef std::map<SocketId, Client::Pointer> ClientList; |
| 69 | - | ||
| 70 |
|
70 | typedef std::map<SocketId, TcpServer::Pointer> ServerList; |
| 71 | 71 | ||
| 72 | static Pointer instance_; |
72 | static Pointer instance_; |
| 73 | 73 | ||
| 74 | ClientList clients_; |
74 | ClientList clients_; |
| - | 75 | ServerList servers_; |
|
| 75 | 76 | ||
| 76 | SignalOnNewState signal_on_new_state_; |
77 | SignalOnNewState signal_on_new_state_; |
| 77 | SignalOnNewData signal_on_new_data_; |
78 | SignalOnNewData signal_on_new_data_; |
| 78 | 79 | ||
| 79 | Manager(); |
80 | Manager(); |
| 80 | 81 | ||
| 81 | void SlotOnNewState(SocketId client_id, SocketId server_id, ClientState client_state); |
82 | void SlotOnNewState(SocketId client_id, SocketId server_id, ClientState client_state); |
| 82 | void SlotOnNewData(SocketId client_id, SocketId server_id, common::Byteset data); |
83 | void SlotOnNewData(SocketId client_id, SocketId server_id, common::Byteset data); |
| - | 84 | void SlotOnNewClient(SocketId server_id, TcpSocketPointer socket); |
|
| 83 | 85 | ||
| 84 | void StopServerHandler(SocketId server_id); |
86 | void StopServerHandler(SocketId server_id); |
| 85 | void DisconnectHandler(SocketId client_id); |
87 | void DisconnectHandler(SocketId client_id); |
| 86 | 88 | ||
| 87 | void SendToAllHandler(SocketId server_id, common::Byteset data); |
89 | void SendToAllHandler(SocketId server_id, common::Byteset data); |