Rev 1916 | Rev 1919 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1916 | Rev 1918 | ||
|---|---|---|---|
| Line 22... | Line 22... | ||
| 22 | 22 | ||
| 23 | #include <boost/lexical_cast.hpp> |
23 | #include <boost/lexical_cast.hpp> |
| 24 | #include <boost/algorithm/string/trim.hpp> |
24 | #include <boost/algorithm/string/trim.hpp> |
| 25 | 25 | ||
| 26 | #include "net/Manager.h" |
26 | #include "net/Manager.h" |
| - | 27 | #include "broker/Manager.h" |
|
| 27 | 28 | ||
| 28 | #include "Message.h" |
29 | #include "Message.h" |
| 29 | 30 | ||
| 30 | namespace atom { |
31 | namespace atom { |
| 31 | namespace can { |
32 | namespace can { |
| Line 61... | Line 62... | ||
| 61 | std::string line = *payload_str; |
62 | std::string line = *payload_str; |
| 62 | 63 | ||
| 63 | net::Manager::Instance()->SendToAll(this->server_id_, common::Byteset(line, true)); |
64 | net::Manager::Instance()->SendToAll(this->server_id_, common::Byteset(line, true)); |
| 64 | } |
65 | } |
| 65 | } |
66 | } |
| 66 | - | ||
| 67 | 67 | ||
| 68 | void CanDaemon::SlotOnNewDataHandler(net::ClientId client_id, net::ServerId server_id, common::Byteset data) |
68 | void CanDaemon::SlotOnNewDataHandler(net::ClientId client_id, net::ServerId server_id, common::Byteset data) |
| 69 | { |
69 | { |
| 70 | if (server_id != this->server_id_) |
70 | if (server_id != this->server_id_) |
| 71 | { |
71 | { |
| 72 | return; |
72 | return; |
| 73 | } |
73 | } |
| 74 | 74 | ||
| 75 | std::string str = data.ToCharString(); |
75 | std::string str = data.ToCharString(); |
| 76 | 76 | ||
| 77 | boost::algorithm::trim_right_if(str, boost::is_any_of("\r\n")); |
77 | boost::algorithm::trim_right_if(str, boost::is_any_of("\r\n")); |
| 78 | 78 | ||
| 79 | LOG. |
79 | LOG.Info("Received: \"" + str + "\" from client " + boost::lexical_cast<std::string>(client_id) + " on server " + boost::lexical_cast<std::string>(server_id)); |
| - | 80 | ||
| - | 81 | std::string* payload_str = new std::string(str); |
|
| - | 82 | broker::Manager::Instance()->Post(broker::Message::Pointer(new broker::Message(broker::Message::CAN_RAW_MESSAGE, broker::Message::PayloadPointer(payload_str), this))); |
|
| - | 83 | ||
| - | 84 | LOG.Info("Sent..."); |
|
| 80 | 85 | ||
| 81 | if (str == "q" || str == "quit") |
86 | if (str == "q" || str == "quit") |
| 82 | { |
87 | { |
| 83 | LOG.Info("Client " + boost::lexical_cast<std::string>(client_id) + " has requested to be disconnected."); |
88 | LOG.Info("Client " + boost::lexical_cast<std::string>(client_id) + " has requested to be disconnected."); |
| 84 | net::Manager::Instance()->Disconnect(client_id); |
89 | net::Manager::Instance()->Disconnect(client_id); |