1 // ============================================================== 2 // This file is part of Glest (www.glest.org) 3 // 4 // Copyright (C) 2001-2008 Marti�o Figueroa 5 // 6 // You can redistribute this code and/or modify it under 7 // the terms of the GNU General Public License as published 8 // by the Free Software Foundation; either version 2 of the 9 // License, or (at your option) any later version 10 // ============================================================== 11 12 #ifndef _GLEST_GAME_SERVERINTERFACE_H_ 13 #define _GLEST_GAME_SERVERINTERFACE_H_ 14 15 #include <vector> 16 17 #include "game_constants.h" 18 #include "network_interface.h" 19 #include "connection_slot.h" 20 #include "socket.h" 21 22 using std::vector; 23 using Shared::Platform::ServerSocket; 24 25 namespace Glest{ namespace Game{ 26 27 // ===================================================== 28 // class ServerInterface 29 // ===================================================== 30 31 class ServerInterface: public GameNetworkInterface{ 32 private: 33 ConnectionSlot* slots[GameConstants::maxPlayers]; 34 ServerSocket serverSocket; 35 36 public: 37 ServerInterface(); 38 virtual ~ServerInterface(); 39 getSocket()40 virtual Socket* getSocket() {return &serverSocket;} getSocket()41 virtual const Socket* getSocket() const {return &serverSocket;} 42 43 //message processing 44 virtual void update(); updateLobby()45 virtual void updateLobby(){}; 46 virtual void updateKeyframe(int frameCount); 47 virtual void waitUntilReady(Checksum* checksum); 48 49 // message sending 50 virtual void sendTextMessage(const string &text, int teamIndex); 51 virtual void quitGame(); 52 53 //misc 54 virtual string getNetworkStatus() const; 55 getServerSocket()56 ServerSocket* getServerSocket() {return &serverSocket;} 57 void addSlot(int playerIndex); 58 void removeSlot(int playerIndex); 59 ConnectionSlot* getSlot(int playerIndex); 60 int getConnectedSlotCount(); 61 62 void launchGame(const GameSettings* gameSettings); 63 64 private: 65 void broadcastMessage(const NetworkMessage* networkMessage, int excludeSlot= -1); 66 void updateListen(); 67 }; 68 69 }}//end namespace 70 71 #endif 72