Subversion Repositories HomeAutomation

Rev

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

Rev 1642 Rev 1959
Line 36... Line 36...
36
class Client
36
class Client
37
{
37
{
38
public:
38
public:
39
    typedef boost::shared_ptr<Client> Pointer;
39
    typedef boost::shared_ptr<Client> Pointer;
40
 
40
 
41
    typedef boost::signals2::signal<void(ClientId, ServerId, ClientState)> SignalOnNewState;
41
    typedef boost::signals2::signal<void(SocketId, SocketId, ClientState)> SignalOnNewState;
42
    typedef boost::signals2::signal<void(ClientId, ServerId, common::Byteset)> SignalOnNewData;
42
    typedef boost::signals2::signal<void(SocketId, SocketId, common::Byteset)> SignalOnNewData;
43
 
43
 
44
    Client(boost::asio::io_service& io_service, ClientId id, ServerId server_id);
44
    Client(boost::asio::io_service& io_service, SocketId id, SocketId server_id);
45
    virtual ~Client();
45
    virtual ~Client();
46
 
46
 
47
    void ConnectSlots(const SignalOnNewState::slot_type& slot_on_new_state, const SignalOnNewData::slot_type& slot_on_new_data);
47
    void ConnectSlots(const SignalOnNewState::slot_type& slot_on_new_state, const SignalOnNewData::slot_type& slot_on_new_data);
48
   
48
   
49
    virtual void Connect(std::string address, unsigned int port_or_baud) = 0;
49
    virtual void Connect(std::string address, unsigned int port_or_baud) = 0;
50
    void Disconnect();
50
    void Disconnect();
51
    virtual void Stop();
51
    virtual void Stop();
52
    virtual void Send(common::Byteset data) = 0;
52
    virtual void Send(common::Byteset data) = 0;
53
 
53
 
54
    ServerId GetServerId();
54
    SocketId GetServerId();
55
    ClientId GetId();
55
    SocketId GetId();
56
   
56
   
57
protected:
57
protected:
58
    common::Byteset buffer_;
58
    common::Byteset buffer_;
59
   
59
   
60
    virtual void Read();
60
    virtual void Read();
61
    void ReadHandler(const boost::system::error_code& error, size_t size);
61
    void ReadHandler(const boost::system::error_code& error, size_t size);
62
   
62
   
63
    SignalOnNewState signal_on_new_state_;
63
    SignalOnNewState signal_on_new_state_;
64
   
64
   
65
private:
65
private:
66
    ClientId id_;
66
    SocketId id_;
67
    ServerId server_id_;
67
    SocketId server_id_;
68
   
68
   
69
    SignalOnNewData signal_on_new_data_;
69
    SignalOnNewData signal_on_new_data_;
70
};
70
};
71
 
71
 
72
}; // namespace net
72
}; // namespace net