#pragma once #include #include #include #include /* MTU */ #define MAX_PACKET_SIZE (1024*1024) class Server { SDL_mutex* mProcessPacketMutex; SDL_TimerID mProcessPacketCallbackTimerID; static Uint32 ProcessPacketCallback (Uint32, void*); public: std::vector UDPsocks; SDLNet_SocketSet SocketSet; UDPpacket **UDPPacketV; Server (void) { UDPsocks.clear (); SocketSet = NULL; UDPPacketV = NULL; mProcessPacketMutex = NULL; } ~Server (void) { // UDP_CloseAll (); // mProcessPacketMutex = SDL_CreateMutex (); // UDPsocks.clear (); // SocketSet = NULL; // UDPPacketV = NULL; } Server (const char* host, const Uint16 port); UDPsocket UDP_Open (Uint16 port); void UDP_CloseAll (void); void ProcessPacket (UDPpacket* packet); int Start (void); int Stop (void); int Lock (void) { return SDL_LockMutex (mProcessPacketMutex); } int Unlock (void) { return SDL_UnlockMutex (mProcessPacketMutex); } };