- make client use less CPU for network games

This commit is contained in:
Mark Vejvoda
2013-03-13 21:32:48 +00:00
parent 3661d62c03
commit 16d25210e4
6 changed files with 92 additions and 25 deletions

View File

@@ -75,13 +75,14 @@ void NetworkInterface::sendMessage(NetworkMessage* networkMessage){
networkMessage->send(socket);
}
NetworkMessageType NetworkInterface::getNextMessageType()
NetworkMessageType NetworkInterface::getNextMessageType(int waitMilliseconds)
{
Socket* socket= getSocket(false);
int8 messageType= nmtInvalid;
if(socket != NULL &&
socket->hasDataToRead() == true) {
((waitMilliseconds <= 0 && socket->hasDataToRead() == true) ||
(waitMilliseconds > 0 && socket->hasDataToReadWithWait(waitMilliseconds) == true))) {
//peek message type
int dataSize = socket->getDataToRead();
if(dataSize >= sizeof(messageType)) {