I've been making a server program and inside the loop I have the server respond to messages from clients.
I've noticed that if the window is in focus it always answers instantaneously, but if the window is not in focus, it does not respond to the clients until it gains focus.
It would seem to me then, that background windows don't process messages until they get focus. Is this correct?
How can I avoid the issue so that my server responds immediately?
My main loop now looks something like this:
while(running)
{
if (PeekMessage( &messages, NULL, 0, 0, PM_REMOVE)!= 0)
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
packet = server->Receive();
if(packet != NULL)
{
HandlePacket(server, packet);
server->DeallocatePacket(packet);
}
for(int i = 0; i < PlayerList.size(); i++)
if(!server->IsActivePlayerID(PlayerList.at(i).ID))
PlayerList.erase(PlayerList.begin()+i);
}
Now I'd like to know if its bad practice to have a bool variable determining the loop of a windows program.
I have WM_CLOSE and WM_DESTROY change the value to false, is there any other condition where Windows would send a message to my program to quit and end up leaving it running still?