Reconnect is now possible.

This commit is contained in:
Jocke
2016-02-10 21:02:46 +01:00
parent 95fa1f4bbd
commit ec54b1298d
5 changed files with 19 additions and 3 deletions
+8 -1
View File
@@ -51,7 +51,10 @@ void TCPClient::Connect(std::string playerName, std::string address, int port)
void TCPClient::Disconnect()
{
m_Socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both);
m_Socket->close();
m_Socket = nullptr;
m_IsConnected = false;
}
void TCPClient::Receive(Packet& packet)
@@ -87,6 +90,10 @@ int TCPClient::readBuffer(char* data)
void TCPClient::Send(Packet & packet)
{
if (!m_Socket) {
LOG_WARNING("TCPClient::Send: Socket is null");
return;
}
packet.UpdateSize();
boost::system::error_code error;
m_Socket->send(boost::asio::buffer(