Rev 1987 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1987 | Rev 1989 | ||
|---|---|---|---|
| Line 129... | Line 129... | ||
| 129 | 129 | ||
| 130 | void Manager::SlotOnNewData(SocketId client_id, SocketId server_id, common::Byteset data) |
130 | void Manager::SlotOnNewData(SocketId client_id, SocketId server_id, common::Byteset data) |
| 131 | { |
131 | { |
| 132 | LOG_DEBUG_ENTER; |
132 | LOG_DEBUG_ENTER; |
| 133 | 133 | ||
| 134 |
|
134 | //log::Debug(log_module_, "data=\"%s\"", std::string(data.begin(), data.end()).data()); |
| 135 | 135 | ||
| 136 | this->signal_on_new_data_(client_id, data); |
136 | this->signal_on_new_data_(client_id, data); |
| 137 | 137 | ||
| 138 | LOG_DEBUG_EXIT; |
138 | LOG_DEBUG_EXIT; |
| 139 | } |
139 | } |
| Line 152... | Line 152... | ||
| 152 | LOG_DEBUG_EXIT; |
152 | LOG_DEBUG_EXIT; |
| 153 | 153 | ||
| 154 | return id; |
154 | return id; |
| 155 | } |
155 | } |
| 156 | 156 | ||
| 157 | SocketId Manager::StartServer( |
157 | SocketId Manager::StartServer(TransportProtocol protocol, unsigned int port) |
| 158 | { |
158 | { |
| 159 | LOG_DEBUG_ENTER; |
159 | LOG_DEBUG_ENTER; |
| 160 | 160 | ||
| 161 | if (protocol != |
161 | if (protocol != TRANSPORT_PROTOCOL_TCP) |
| 162 | { |
162 | { |
| 163 | throw std::runtime_error("Can not start server for the Serial or UDP protocol!"); |
163 | throw std::runtime_error("Can not start server for the Serial or UDP protocol!"); |
| 164 | } |
164 | } |
| 165 | 165 | ||
| 166 | TcpServer::Pointer server = TcpServer::Pointer(new TcpServer(this->io_service_, port, this->GetFreeSocketId())); |
166 | TcpServer::Pointer server = TcpServer::Pointer(new TcpServer(this->io_service_, port, this->GetFreeSocketId())); |
| Line 176... | Line 176... | ||
| 176 | LOG_DEBUG_EXIT; |
176 | LOG_DEBUG_EXIT; |
| 177 | 177 | ||
| 178 | return server->GetId(); |
178 | return server->GetId(); |
| 179 | } |
179 | } |
| 180 | 180 | ||
| 181 | SocketId Manager::Connect( |
181 | SocketId Manager::Connect(TransportProtocol protocol, std::string address, unsigned int port_or_baud) |
| 182 | { |
182 | { |
| 183 | LOG_DEBUG_ENTER; |
183 | LOG_DEBUG_ENTER; |
| 184 | 184 | ||
| 185 | Client::Pointer client; |
185 | Client::Pointer client; |
| 186 | 186 | ||
| 187 | switch (protocol) |
187 | switch (protocol) |
| 188 | { |
188 | { |
| 189 | case |
189 | case TRANSPORT_PROTOCOL_TCP: |
| 190 | { |
190 | { |
| 191 | client = Client::Pointer(new TcpClient(this->io_service_, this->GetFreeSocketId(), 0)); |
191 | client = Client::Pointer(new TcpClient(this->io_service_, this->GetFreeSocketId(), 0)); |
| 192 | break; |
192 | break; |
| 193 | } |
193 | } |
| 194 | case |
194 | case TRANSPORT_PROTOCOL_UDP: |
| 195 | { |
195 | { |
| 196 | client = Client::Pointer(new UdpClient(this->io_service_, this->GetFreeSocketId(), 0)); |
196 | client = Client::Pointer(new UdpClient(this->io_service_, this->GetFreeSocketId(), 0)); |
| 197 | break; |
197 | break; |
| 198 | } |
198 | } |
| 199 | case |
199 | case TRANSPORT_PROTOCOL_SERIAL: |
| 200 | { |
200 | { |
| 201 | client = Client::Pointer(new SerialClient(this->io_service_, this->GetFreeSocketId(), 0)); |
201 | client = Client::Pointer(new SerialClient(this->io_service_, this->GetFreeSocketId(), 0)); |
| 202 | break; |
202 | break; |
| 203 | } |
203 | } |
| 204 | default: |
204 | default: |