Moved client and server from header.

Fixed so user are able to start a server and client on the same computer.
Starting 2 servers on the same computer will probably still crash the newest server (Don't do it).
This commit is contained in:
Jocke
2015-12-09 17:50:30 +01:00
parent 0807a7d0ae
commit 663aca2641
3 changed files with 18 additions and 9 deletions
+14 -5
View File
@@ -206,11 +206,20 @@ void Client::ParseSnapshot(char* data, size_t length)
int Client::Receive(char* data, size_t length)
{
int bytesReceived = m_Socket.receive_from(boost
::asio::buffer((void*)data, length),
m_ReceiverEndpoint,
0);
return bytesReceived;
try {
int bytesReceived = m_Socket.receive_from(boost
::asio::buffer((void*)data, length),
m_ReceiverEndpoint,
0);
return bytesReceived;
} catch (const std::exception& err) {
// To not spam "socket closed messages"
//if (std::string(err.what()).find("forcefully closed") != std::string::npos) {
std::cout << "Read from client crashed: " << err.what();
//}
}
return 0;
}
int Client::CreateMessage(MessageType type, std::string message, char* data)