Subversion Repositories HomeAutomation

Rev

Rev 1939 | Rev 1962 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1939 Rev 1959
Line 42... Line 42...
42
class Manager : public common::IoService
42
class Manager : public common::IoService
43
{
43
{
44
public:
44
public:
45
    typedef boost::shared_ptr<Manager> Pointer;
45
    typedef boost::shared_ptr<Manager> Pointer;
46
 
46
 
47
    typedef boost::signals2::signal<void(ClientId, ServerId, ClientState)> SignalOnNewState;
47
    typedef boost::signals2::signal<void(SocketId, SocketId, ClientState)> SignalOnNewState;
48
    typedef boost::signals2::signal<void(ClientId, ServerId, common::Byteset)> SignalOnNewData;
48
    typedef boost::signals2::signal<void(SocketId, SocketId, common::Byteset)> SignalOnNewData;
49
 
49
 
50
    virtual ~Manager();
50
    virtual ~Manager();
51
 
51
 
52
    static Pointer Instance();
52
    static Pointer Instance();
53
    static void Create();
53
    static void Create();
54
    static void Delete();
54
    static void Delete();
55
   
55
   
56
    void ConnectSlots(const SignalOnNewState::slot_type& slot_on_new_state, const SignalOnNewData::slot_type& slot_on_new_data);
56
    void ConnectSlots(const SignalOnNewState::slot_type& slot_on_new_state, const SignalOnNewData::slot_type& slot_on_new_data);
57
   
57
   
58
    ServerId StartServer(Protocol protocol, unsigned int port);
58
    SocketId StartServer(Protocol protocol, unsigned int port);
59
    ClientId Connect(Protocol protocol, std::string address, unsigned int port_or_baud);
59
    SocketId Connect(Protocol protocol, std::string address, unsigned int port_or_baud);
60
   
60
   
61
    void StopServer(ServerId server_id);
61
    void StopServer(SocketId server_id);
62
    void Disconnect(ClientId client_id);
62
    void Disconnect(SocketId client_id);
63
   
63
   
64
    void SendToAll(ServerId server_id, common::Byteset data);
64
    void SendToAll(SocketId server_id, common::Byteset data);
65
    void SendTo(ClientId client_id, common::Byteset data);
65
    void SendTo(SocketId client_id, common::Byteset data);
66
 
66
 
67
private:
67
private:
68
    typedef std::map<ClientId, Client::Pointer> ClientList;
68
    typedef std::map<SocketId, Client::Pointer> ClientList;
69
 
69
 
70
    static logging::Logger LOG;
70
    static logging::Logger LOG;
71
   
71
   
72
    static Pointer instance_;
72
    static Pointer instance_;
73
   
73
   
Line 76... Line 76...
76
    SignalOnNewState signal_on_new_state_;
76
    SignalOnNewState signal_on_new_state_;
77
    SignalOnNewData signal_on_new_data_;
77
    SignalOnNewData signal_on_new_data_;
78
   
78
   
79
    Manager();
79
    Manager();
80
   
80
   
81
    void SlotOnNewState(ClientId client_id, ServerId server_id, ClientState client_state);
81
    void SlotOnNewState(SocketId client_id, SocketId server_id, ClientState client_state);
82
    void SlotOnNewData(ClientId client_id, ServerId server_id, common::Byteset data);
82
    void SlotOnNewData(SocketId client_id, SocketId server_id, common::Byteset data);
83
   
83
   
84
    void StopServerHandler(ServerId server_id);
84
    void StopServerHandler(SocketId server_id);
85
    void DisconnectHandler(ClientId client_id);
85
    void DisconnectHandler(SocketId client_id);
86
   
86
   
87
    void SendToAllHandler(ServerId server_id, common::Byteset data);
87
    void SendToAllHandler(SocketId server_id, common::Byteset data);
88
    void SendToHandler(ClientId client_id, common::Byteset data);
88
    void SendToHandler(SocketId client_id, common::Byteset data);
89
   
89
   
90
    ClientId GetFreeClientId();
-
 
91
    ServerId GetFreeServerId();
90
    SocketId GetFreeSocketId();
92
};
91
};
93
 
92
 
94
}; // namespace net
93
}; // namespace net
95
}; // namespace atom
94
}; // namespace atom
96
 
95