Rev 1599 | Rev 1962 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1599 | Rev 1642 | ||
|---|---|---|---|
| Line 24... | Line 24... | ||
| 24 | #include <boost/asio.hpp> |
24 | #include <boost/asio.hpp> |
| 25 | #include <boost/signals2.hpp> |
25 | #include <boost/signals2.hpp> |
| 26 | #include <boost/shared_ptr.hpp> |
26 | #include <boost/shared_ptr.hpp> |
| 27 | #include <boost/array.hpp> |
27 | #include <boost/array.hpp> |
| 28 | 28 | ||
| 29 | #include " |
29 | #include "common/Byteset.h" |
| 30 | 30 | ||
| 31 | #include "types.h" |
31 | #include "types.h" |
| 32 | 32 | ||
| 33 | namespace atom { |
33 | namespace atom { |
| 34 | namespace net { |
34 | namespace net { |
| Line 37... | Line 37... | ||
| 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(ClientId, ServerId, ClientState)> SignalOnNewState; |
| 42 | typedef boost::signals2::signal<void(ClientId, ServerId, |
42 | typedef boost::signals2::signal<void(ClientId, ServerId, 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, ClientId id, ServerId 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( |
52 | virtual void Send(common::Byteset data) = 0; |
| 53 | 53 | ||
| 54 | ServerId GetServerId(); |
54 | ServerId GetServerId(); |
| 55 | ClientId GetId(); |
55 | ClientId GetId(); |
| 56 | 56 | ||
| 57 | protected: |
57 | protected: |
| 58 |
|
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_; |