When creating a network game, a client is also started.

Network errors are handled globally.
Fixed last network thread issue by using a notification queue, should work fine now.
This commit is contained in:
lotodore
2007-03-20 14:05:16 +00:00
parent 7a704c2995
commit 62e72617ba
9 changed files with 172 additions and 100 deletions
+12 -2
View File
@@ -31,6 +31,9 @@
#define RECEIVER_THREAD_TERMINATE_TIMEOUT 200
// Notifications
#define NOTIFY_GAME_START 1
class ServerRecvState;
class SenderThread;
class ReceiverHelper;
@@ -43,17 +46,21 @@ public:
ServerRecvThread();
virtual ~ServerRecvThread();
void StartGame();
void SendToAllPlayers(boost::shared_ptr<NetPacket> packet);
void AddConnection(boost::shared_ptr<ConnectData> data);
void AddNotification(unsigned notification);
protected:
typedef std::deque<boost::shared_ptr<ConnectData> > ConnectQueue;
typedef std::map<SOCKET, boost::shared_ptr<SessionData> > SocketSessionMap;
typedef std::deque<unsigned> NotificationQueue;
// Main function of the thread.
virtual void Main();
void NotificationLoop();
SOCKET Select();
void CleanupConnectQueue();
@@ -72,10 +79,13 @@ protected:
private:
std::deque<boost::shared_ptr<ConnectData> > m_connectQueue;
ConnectQueue m_connectQueue;
mutable boost::mutex m_connectQueueMutex;
ServerRecvState *m_curState;
NotificationQueue m_notificationQueue;
mutable boost::mutex m_notificationQueueMutex;
SocketSessionMap m_sessionMap;
mutable boost::mutex m_sessionMapMutex;