|
|
|
|
@ -17,6 +17,7 @@ int tcp_client::create(std::string addrstr, std::string passwd)
|
|
|
|
|
local_server.reset(new tcp_server(ioc, addrstr, port, passwd)); |
|
|
|
|
return join(local_server->localhost_self(), passwd); |
|
|
|
|
} catch (std::system_error &e) { |
|
|
|
|
eprintf("%s\n", e.what()); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -33,6 +34,7 @@ int tcp_client::join(std::string addrstr, std::string passwd)
|
|
|
|
|
asio::ip::tcp::no_delay option(true); |
|
|
|
|
sock.set_option(option); |
|
|
|
|
} catch (std::exception &e) { |
|
|
|
|
eprintf("%s\n", e.what()); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
start_recv(); |
|
|
|
|
@ -104,5 +106,11 @@ void tcp_client::send(packet &pkt)
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool tcp_client::SNetLeaveGame(int type){ |
|
|
|
|
if(sock.is_open()) |
|
|
|
|
sock.close(); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace net
|
|
|
|
|
} // namespace dvl
|
|
|
|
|
|