home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 March / ENTER.ISO / files / fwp-0.0.6-win32-installer.exe / Server.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-12-19  |  2.0 KB  |  76 lines

  1. #ifndef __Server_h__
  2. #define __Server_h__
  3.  
  4. //#include "SDL/SDL_net.h"
  5. #include "Client.h"
  6. #include "PacketHandler.h"
  7.  
  8. //#define SERVER_MAX_CLIENTS    32
  9.  
  10. class Server{
  11. public:
  12.     IPaddress ipAddress;
  13.     UDPsocket socket;
  14.  
  15.     serverinfoPacket_t si;
  16.     Client* clients[16/*NETWORK_MAX_CLIENTS*/];
  17.     Client* localClient;
  18.  
  19.     unsigned long lastPingMillis;
  20.     unsigned long lastPlayerinfoMillis;
  21.     unsigned long lastGamestateMillis;
  22.  
  23.     Server();
  24.     ~Server();
  25.  
  26. //    void displayServerInfo();
  27.  
  28.     bool openPort();
  29.     bool closePort();
  30.  
  31.     bool disconnectAllClients(const char* reason);
  32.     bool disconnectClient(Client* client, const char* reason);
  33.  
  34.     int addClient(Client* client);
  35.     void removeClient(Client* client);
  36.     void checkClientName(char* name, char* newName);
  37.     bool hasFreeSlots();
  38.     Client* getClientByPacket(UDPpacket* packet);
  39.     Client* getClientByName(const char* name);
  40.     void resetClients();
  41.  
  42.     bool sendToClient(Client* client, UDPpacket* packet);
  43.     bool sendToAllClients(UDPpacket* packet);
  44.     bool sendToAllRemoteClients(UDPpacket* packet);
  45.     bool sendToAllOtherRemoteClients(Client* c, UDPpacket* packet);
  46.  
  47.     void sendGamestate();
  48.     void sendPlayerinfo();
  49.     void sendPing();
  50.     void sendClientHurt(char hurtClientId, char hurterClientId, unsigned char amount);
  51.     void sendClientKill(char killedClientId, char killerClientId, char weapon);
  52.     void sendChatMessage(const char* message);
  53.     void sendArenaChange();
  54.  
  55.     void sendPackets();
  56.     void receivePackets();
  57.     void emptyPacketQueue();
  58.  
  59.     void handlePacket(UDPpacket* packet);
  60.     void handlePing(UDPpacket* packet);
  61.     void handleServerinfoRequest(UDPpacket* packet);
  62. //    void handlePlayerinfoRequest(UDPpacket* packet);
  63.     void handleConnectionRequest(UDPpacket* packet);
  64.     void handleDisconnect(UDPpacket* packet);
  65.  
  66.     void handleChatMessage(UDPpacket* packet);
  67.     void handleVoiceMessage(UDPpacket* packet);
  68.     void handleClientstate(UDPpacket* packet);
  69.     void handleClientSpawn(UDPpacket* packet);
  70.     void handleClientKill(UDPpacket* packet);
  71.     void handleShotSpawn(UDPpacket* packet);
  72. };
  73.  
  74.  
  75. #endif    /* __Server_h__ */
  76.