| 371 | } |
| 372 | |
| 373 | void ConnectToServer(const asio::ip::tcp::resolver::results_type& endpoints) |
| 374 | { |
| 375 | // Only clients can connect to servers |
| 376 | if (m_nOwnerType == owner::client) |
| 377 | { |
| 378 | // Request asio attempts to connect to an endpoint |
| 379 | asio::async_connect(m_socket, endpoints, |
| 380 | [this](std::error_code ec, asio::ip::tcp::endpoint endpoint) |
| 381 | { |
| 382 | if (!ec) |
| 383 | { |
| 384 | // Was: ReadHeader(); |
| 385 | |
| 386 | // First thing server will do is send packet to be validated |
| 387 | // so wait for that and respond |
| 388 | ReadValidation(); |
| 389 | } |
| 390 | }); |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | |
| 395 | void Disconnect() |