return to while
This commit is contained in:
@@ -125,19 +125,16 @@ bool ClientModule::onEvent(const Archimedes::Event& event) {
|
|||||||
|
|
||||||
void ClientModule::pollIncomingData() {
|
void ClientModule::pollIncomingData() {
|
||||||
|
|
||||||
int numMsgs;
|
while(running) {
|
||||||
do {
|
|
||||||
ISteamNetworkingMessage *pIncomingMsg = nullptr;
|
ISteamNetworkingMessage *pIncomingMsg = nullptr;
|
||||||
numMsgs = interface->ReceiveMessagesOnConnection( connection, &pIncomingMsg, 1 );
|
int numMsgs = interface->ReceiveMessagesOnConnection( connection, &pIncomingMsg, 1 );
|
||||||
if ( numMsgs == 0 )
|
if ( numMsgs == 0 )
|
||||||
return;
|
break;
|
||||||
if ( numMsgs < 0 )
|
if ( numMsgs < 0 )
|
||||||
std::cerr << "Error checking for messages" << std::endl;
|
std::cerr << "Error checking for messages" << std::endl;
|
||||||
assert( numMsgs == 1 && pIncomingMsg );
|
assert( numMsgs == 1 && pIncomingMsg );
|
||||||
assert( pIncomingMsg->m_conn == connection );
|
assert( pIncomingMsg->m_conn == connection );
|
||||||
|
|
||||||
app->emitEvent(new CMEvent::DataRecievedEvent(pIncomingMsg));
|
app->emitEvent(new CMEvent::DataRecievedEvent(pIncomingMsg));
|
||||||
//numMsgs--;
|
}
|
||||||
return;
|
|
||||||
} while (numMsgs > 0);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ void ServerModule::pollIncomingData() {
|
|||||||
ISteamNetworkingMessage *pIncomingMsg = nullptr;
|
ISteamNetworkingMessage *pIncomingMsg = nullptr;
|
||||||
int numMsgs = interface->ReceiveMessagesOnPollGroup( pollGroup, &pIncomingMsg, 1 );
|
int numMsgs = interface->ReceiveMessagesOnPollGroup( pollGroup, &pIncomingMsg, 1 );
|
||||||
if ( numMsgs == 0 )
|
if ( numMsgs == 0 )
|
||||||
return;
|
break;
|
||||||
if ( numMsgs < 0 )
|
if ( numMsgs < 0 )
|
||||||
std::cerr << "Error checking for messages" << std::endl;
|
std::cerr << "Error checking for messages" << std::endl;
|
||||||
assert( numMsgs == 1 && pIncomingMsg );
|
assert( numMsgs == 1 && pIncomingMsg );
|
||||||
@@ -217,6 +217,5 @@ void ServerModule::pollIncomingData() {
|
|||||||
assert( itClient != clients.end() );
|
assert( itClient != clients.end() );
|
||||||
|
|
||||||
app->emitEvent(new SMEvent::DataRecievedEvent(pIncomingMsg));
|
app->emitEvent(new SMEvent::DataRecievedEvent(pIncomingMsg));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user