I'm planning on how my multiplayer game client game loop should work. While I'm convinced that server should be moved from game loop into it's own thread, I'm not sure what should I do about receiving server data. To me most logical approach would be something like this:
protected override void Update(GameTime gameTime)
{
receiveServerData(); //may receiving data lag the game?
updateWorld();
processInput();
sendClientMovementToServer();
}
private void receiveServerData()
{
NetIncomingMessage msg;
while ((msg = netClient.ReadMessage()) != null)
{
// ...
}
}
But I'm afraid that reading incoming data inside game loop can lag the game if processing too much data, so here's my question: Is it good idea to process incoming server data inside game loop, or should create thread for receiving this data instead? And if so, how should I do it?