Rev 1986 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1986 | Rev 1987 | ||
|---|---|---|---|
| Line 113... | Line 113... | ||
| 113 | line += " " + it->first + "=" + it->second; |
113 | line += " " + it->first + "=" + it->second; |
| 114 | } |
114 | } |
| 115 | 115 | ||
| 116 | line += "\n"; |
116 | line += "\n"; |
| 117 | 117 | ||
| 118 | net::Manager::Instance()->SendToAll(this->server_id_, common::Byteset(line)); |
118 | net::Manager::Instance()->SendToAll(this->server_id_, common::Byteset(line.begin(), line.end())); |
| 119 | } |
119 | } |
| 120 | } |
120 | } |
| 121 | 121 | ||
| 122 | void Monitor::SlotOnNewDataHandler(net::SocketId id, common::Byteset data) |
122 | void Monitor::SlotOnNewDataHandler(net::SocketId id, common::Byteset data) |
| 123 | { |
123 | { |
| 124 | if (std::find(this->clients_.begin(), this->clients_.end(), id) == this->clients_.end()) |
124 | if (std::find(this->clients_.begin(), this->clients_.end(), id) == this->clients_.end()) |
| 125 | { |
125 | { |
| 126 | return; |
126 | return; |
| 127 | } |
127 | } |
| 128 | 128 | ||
| 129 | std::string str |
129 | std::string str(data.begin(), data.end()); |
| 130 | 130 | ||
| 131 | boost::algorithm::trim_right_if(str, boost::is_any_of("\r\n")); |
131 | boost::algorithm::trim_right_if(str, boost::is_any_of("\r\n")); |
| 132 | 132 | ||
| 133 | LOG.Debug("Received: \"" + str + "\" from client " + boost::lexical_cast<std::string>(id) + " on server " + boost::lexical_cast<std::string>(this->server_id_)); |
133 | LOG.Debug("Received: \"" + str + "\" from client " + boost::lexical_cast<std::string>(id) + " on server " + boost::lexical_cast<std::string>(this->server_id_)); |
| 134 | 134 | ||
| Line 160... | Line 160... | ||
| 160 | this->clients_.erase(id); |
160 | this->clients_.erase(id); |
| 161 | } |
161 | } |
| 162 | else if (client_state == net::CLIENT_STATE_CONNECTED) |
162 | else if (client_state == net::CLIENT_STATE_CONNECTED) |
| 163 | { |
163 | { |
| 164 | LOG.Info("Client " + boost::lexical_cast<std::string>(id) + " has connected."); |
164 | LOG.Info("Client " + boost::lexical_cast<std::string>(id) + " has connected."); |
| - | 165 | ||
| - | 166 | std::string message = "Welcome to Atom CAN monitoring\n"; |
|
| - | 167 | ||
| 165 | net::Manager::Instance()->SendTo(id, common::Byteset( |
168 | net::Manager::Instance()->SendTo(id, common::Byteset(message.begin(), message.end())); |
| 166 | } |
169 | } |
| 167 | else |
170 | else |
| 168 | { |
171 | { |
| 169 | LOG.Debug("Got state: " + boost::lexical_cast<std::string>((int)client_state)); |
172 | LOG.Debug("Got state: " + boost::lexical_cast<std::string>((int)client_state)); |
| 170 | } |
173 | } |