Add callback to NetworkServer to handle UI updates when client information changes

This commit is contained in:
Adam Honse 2020-05-08 21:53:53 -05:00
parent 3ad0986ae7
commit 9ff4314840
3 changed files with 64 additions and 8 deletions

View file

@ -6,6 +6,8 @@
#pragma once
typedef void (*NetServerCallback)(void *);
struct NetworkClientInfo
{
SOCKET client_sock;
@ -25,6 +27,8 @@ public:
const char * GetClientString(unsigned int client_num);
const char * GetClientIP(unsigned int client_num);
void RegisterClientInfoChangeCallback(NetServerCallback, void * new_callback_arg);
void SetPort(unsigned short new_port);
void StartServer();
@ -45,6 +49,9 @@ protected:
std::vector<NetworkClientInfo *> ServerClients;
std::thread * ConnectionThread;
std::vector<NetServerCallback> ClientInfoChangeCallbacks;
std::vector<void *> ClientInfoChangeCallbackArgs;
private:
#ifdef WIN32
WSADATA wsa;