home *** CD-ROM | disk | FTP | other *** search
- #ifndef __Client_h__
- #define __Client_h__
-
- //#include "SDL/SDL_net.h"
- #include "PacketHandler.h"
-
- #define CLIENT_MAX_NAME_LENGTH 32
-
- class Vehicle;
- class Shot;
-
- class Client{
- public:
- IPaddress ipAddress;
- UDPsocket socket;
- // char name[CLIENT_MAX_NAME_LENGTH];
- int clientId;
- // int ping;
- unsigned long lastPingMillis;
- unsigned long momentOfConnectMillis; // only for server!
- // int secondsOnServer;
- unsigned long lastClientstateMillis;
- unsigned long nextSpawnMillis;
- unsigned long lastSpawnMillis;
- // bool isReady;
-
- clientinfoPacket_t ci;
- clientstatePacket_t cs;
-
- Vehicle* vehicle;
-
- Client();
- ~Client();
-
- // void fillInPlayerInfo(playerinfoPacket_t* pi, int index);
- void setName(char* newName);
- int getClientId();
- // bool makeLoopbackConnection();
- bool openPort();
- bool closePort();
-
- bool connect();
- bool disconnect();
- // bool getServerinfo();
- // bool getPlayerinfo();
-
- void sendChatMessage(unsigned char mode, const char* message);
- void sendVoiceMessage(unsigned char mode, char messageId);
- void sendClientstate();
- void sendClientSpawn();
- void sendClientKill();
- void sendShotSpawn(Shot* shot);
-
- void sendPackets();
- void receivePackets();
- void handlePacket(UDPpacket* packet);
- void emptyPacketQueue();
-
- void handlePing(UDPpacket* packet);
- void handleDisconnect(UDPpacket* packet);
- void handleClientConnected(UDPpacket* packet);
- void handleClientDisconnected(UDPpacket* packet);
-
- void handleChatMessage(UDPpacket* packet);
- void handleVoiceMessage(UDPpacket* packet);
- void handlePlayerinfo(UDPpacket* packet);
- void handleGamestate(UDPpacket* packet);
- void handleClientSpawn(UDPpacket* packet);
- void handleClientHurt(UDPpacket* packet);
- void handleClientKill(UDPpacket* packet);
- void handleShotSpawn(UDPpacket* packet);
- void handleArenaChange(UDPpacket* packet);
- };
-
- #endif /* __Client_h__ */
-