Rev 1595 | Rev 1599 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1595 | Rev 1596 | ||
|---|---|---|---|
| Line 24... | Line 24... | ||
| 24 | #include <boost/lexical_cast.hpp> |
24 | #include <boost/lexical_cast.hpp> |
| 25 | 25 | ||
| 26 | namespace atom { |
26 | namespace atom { |
| 27 | namespace net { |
27 | namespace net { |
| 28 | 28 | ||
| 29 | Client::Client(boost::asio::io_service& io_service, ClientId id, ServerId server_id) |
29 | Client::Client(boost::asio::io_service& io_service, ClientId id, ServerId server_id) : buffer_(2048) |
| 30 | { |
30 | { |
| 31 | this->server_id_ = server_id; |
31 | this->server_id_ = server_id; |
| 32 | this->id_ = id; |
32 | this->id_ = id; |
| 33 | } |
33 | } |
| 34 | 34 | ||
| Line 52... | Line 52... | ||
| 52 | return this->server_id_; |
52 | return this->server_id_; |
| 53 | } |
53 | } |
| 54 | 54 | ||
| 55 | void Client::Read() |
55 | void Client::Read() |
| 56 | { |
56 | { |
| 57 | this->buffer_. |
57 | this->buffer_.Clear(); |
| 58 | } |
58 | } |
| 59 | 59 | ||
| 60 | void Client::ReadHandler(const boost::system::error_code& error, size_t size) |
60 | void Client::ReadHandler(const boost::system::error_code& error, size_t size) |
| 61 | { |
61 | { |
| 62 | if (error) |
62 | if (error) |
| Line 68... | Line 68... | ||
| 68 | //std::cout << "ReadHandler size 0" << std::endl; |
68 | //std::cout << "ReadHandler size 0" << std::endl; |
| 69 | this->Disconnect(); |
69 | this->Disconnect(); |
| 70 | } |
70 | } |
| 71 | else |
71 | else |
| 72 | { |
72 | { |
| - | 73 | this->buffer_.SetSize(size); |
|
| - | 74 | ||
| 73 | this->signal_on_new_data_(this->id_, this->server_id_, this->buffer_); |
75 | this->signal_on_new_data_(this->id_, this->server_id_, this->buffer_); |
| 74 | 76 | ||
| 75 | this->Read(); |
77 | this->Read(); |
| 76 | } |
78 | } |
| 77 | } |
79 | } |