46b2ed80ae
Another nuke! This time, trying to do a client <-> server thing. Also a bit of messing with Lua.
39 lines
808 B
C++
39 lines
808 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <SDL.h>
|
|
#include <SDL_net.h>
|
|
|
|
/* MTU */
|
|
#define MAX_PACKET_SIZE (1024*1024)
|
|
|
|
class Server
|
|
{
|
|
bool mProcessPacketCallbackRunning;
|
|
SDL_TimerID mProcessPacketCallbackTimerID;
|
|
static Uint32 ProcessPacketCallback (Uint32, void*);
|
|
public:
|
|
std::vector<UDPsocket> UDPsocks;
|
|
SDLNet_SocketSet SocketSet;
|
|
UDPpacket **UDPPacketV;
|
|
Server (void)
|
|
{
|
|
mProcessPacketCallbackRunning = false;
|
|
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);
|
|
void Start (void);
|
|
void Stop (void);
|
|
bool ProcessPacketCallbackRunning (void)
|
|
{
|
|
return mProcessPacketCallbackRunning;
|
|
}
|
|
};
|