Major redesign: The game can not be left without disconnecting from the server. This happens if a player is kicked, if he wishes to leave, or for other reasons. Error packets from the server will always cause a disconnect, however.
If joining a game fails, there is a proper failure packet now.
This commit is contained in:
@@ -51,7 +51,8 @@ public:
|
||||
void Init(const std::string &pwd);
|
||||
|
||||
void AddConnection(boost::shared_ptr<ConnectData> data);
|
||||
void CloseSessionDelayed(SessionWrapper session);
|
||||
void ReAddSession(SessionWrapper session, int reason);
|
||||
void SessionError(SessionWrapper session, int errorCode);
|
||||
void NotifyPlayerJoinedGame(unsigned gameId, unsigned playerId);
|
||||
void NotifyPlayerLeftGame(unsigned gameId, unsigned playerId);
|
||||
|
||||
@@ -64,6 +65,7 @@ public:
|
||||
protected:
|
||||
|
||||
typedef std::deque<boost::shared_ptr<ConnectData> > ConnectQueue;
|
||||
typedef std::deque<SessionWrapper> SessionQueue;
|
||||
typedef std::list<SessionWrapper> SessionList;
|
||||
typedef std::list<std::pair<boost::timers::portable::microsec_timer, boost::shared_ptr<SessionData> > > CloseSessionList;
|
||||
typedef std::map<unsigned, boost::shared_ptr<ServerGameThread> > GameMap;
|
||||
@@ -86,14 +88,17 @@ protected:
|
||||
void TerminateGames();
|
||||
|
||||
void HandleNewConnection(boost::shared_ptr<ConnectData> connData);
|
||||
void HandleNewSession(SessionWrapper session);
|
||||
|
||||
SOCKET Select();
|
||||
|
||||
void CleanupConnectQueue();
|
||||
void CleanupSessionMap();
|
||||
|
||||
void SessionError(SessionWrapper session, int errorCode);
|
||||
void CloseSessionDelayed(SessionWrapper session);
|
||||
void SendError(SOCKET s, int errorCode);
|
||||
void SendJoinGameFailed(SOCKET s, int reason);
|
||||
void SendGameList(SOCKET s);
|
||||
|
||||
SenderThread &GetSender();
|
||||
ReceiverHelper &GetReceiver();
|
||||
@@ -113,6 +118,9 @@ private:
|
||||
ConnectQueue m_connectQueue;
|
||||
mutable boost::mutex m_connectQueueMutex;
|
||||
|
||||
SessionQueue m_sessionQueue;
|
||||
mutable boost::mutex m_sessionQueueMutex;
|
||||
|
||||
SessionManager m_sessionManager;
|
||||
|
||||
CloseSessionList m_closeSessionList;
|
||||
|
||||
Reference in New Issue
Block a user