I'm doing the following:
#ifdef _WIN32#include "Kbhit.h"#endif#if defined(_CONSOLE_2)#include "Console2SampleIncludes.h"#endif#ifdef _CONSOLE_2_CONSOLE_2_SetSystemProcessParams#endif//... while(!server->shouldQuit) server->Update();
Update() from Server.cpp
void Server::Update(){ char message[2048];#ifdef _WIN32 if (_kbhit()) { gets(message); if (strcmp(message, "quit") == 0) { puts("Quitting."); shouldQuit = true; } if (strcmp(message, "ping") == 0) { server->Ping(clientID); } if (strcmp(message, "clear") == 0) { system("CLS"); } // Message now holds what we want to broadcast char message2[2048]; // Append Server: to the message so clients know that it ORIGINATED from the server all messages to all clients come from the server either directly or by being relayed from other clients message2[0] = 0; strcpy(message2, "Server: "); strcat(message2, message); // We arbitrarily pick 0 for the ordering stream, UNASSIGNED_SYSTEM_ADDRESS means don't exclude anyone from the broadcast, true means broadcast the message to everyone connected server->Send(message2, (const int) strlen(message2) + 1, HIGH_PRIORITY, RELIABLE_ORDERED, 0, UNASSIGNED_SYSTEM_ADDRESS, true); }#endif // Get a packet from either the server or the client for (p = server->Receive(); p; server->DeallocatePacket(p), p = server->Receive()) { // We got a packet, get the identifier with our handy function packetIdentifier = GetPacketIdentifier(p); // Check if this is a network message packet switch (packetIdentifier) { case ID_DISCONNECTION_NOTIFICATION: // Connection lost normally removePlayer(p->systemAddress); printf("DISCONNECTION_NOTIFICATION from %s\n", p->systemAddress.ToString(true)); } }}
In short, it is refreshing (loop) received the message and waits for User Commands (gets (message))
I like to do something in a window (using QT), ie, it is refreshing to receive the message (loop) and waits for commands (buttons, text, etc ...)
how could I do?
Thanks