00001 #ifndef _NETMANAGERSERVER_H_ 00002 #define _NETMANAGERSERVER_H_ 00003 00004 #include "netmanager.h" 00005 00017 class NetManagerServer : public NetManager { 00018 public: 00024 NetManagerServer(); 00025 00029 ~NetManagerServer(); 00030 00045 void send(MessagePacket& msg, unsigned socketIndex, bool immediate=true); 00046 00059 void send(const string& msg, unsigned socketIndex, bool immediate=true); 00060 00067 void flush(unsigned socketIndex); 00068 00077 MessagePacket next(); 00078 00086 vector<int> getNewClients(); 00087 00096 vector<int> getTimedOutClients(); 00097 00103 bool thereAreNewClients() const {return !newClients.empty();}; 00104 00110 bool thereAreTimedOutClients() const {return !timedOutClients.empty();}; 00111 00118 void dismissClient(int client); 00119 00125 void flush(); 00126 00135 bool isTimedOut(unsigned client) const; 00136 00142 static const Uint32 TIMEOUT; 00143 00144 private: 00150 virtual void onReception(unsigned client); 00151 00156 virtual bool forwardMessage(const MessagePacket& msg, IPaddress* ip); 00157 00164 int findClient(const IPaddress* ip) const; 00165 00172 int registerClient(IPaddress* ip); 00173 00178 void acknowledgeClient(int client); 00179 00184 vector<UDPsocket> senderSockets; 00185 00192 vector<MessagePacket> outputBuffer; 00193 00199 vector<bool> validClients; 00200 00204 int msgCount; 00205 00209 vector<int> newClients; 00210 00214 vector<int> timedOutClients; 00215 00219 vector<Uint32> lastMsgTime; 00220 }; 00221 00222 #endif
1.2.15