One sender thread per client. Requires loads of resources. Kind of hacked, because the internal dependencies are very ugly now. Requires loads of testing. A problem might be the last packet sent by the server to a specific client before closing the connection, for example an error message. It might never even reach the client, because the sender thread is terminated before. I have not yet found a good way to fix this.
This commit is contained in:
@@ -32,13 +32,16 @@
|
||||
#define SESSION_ID_GENERIC 0xFFFFFFFF
|
||||
|
||||
typedef unsigned SessionId;
|
||||
class SenderThread;
|
||||
class SenderInterface;
|
||||
class SenderCallback;
|
||||
|
||||
class SessionData
|
||||
{
|
||||
public:
|
||||
enum State { Init, ReceivingAvatar, Established, Game };
|
||||
|
||||
SessionData(SOCKET sockfd, SessionId id);
|
||||
SessionData(SOCKET sockfd, SessionId id, SenderCallback &cb);
|
||||
~SessionData();
|
||||
|
||||
SessionId GetId() const;
|
||||
@@ -58,6 +61,7 @@ public:
|
||||
void SetClientAddr(const std::string &addr);
|
||||
|
||||
ReceiveBuffer &GetReceiveBuffer();
|
||||
SenderInterface &GetSender();
|
||||
|
||||
void ResetActivityTimer();
|
||||
unsigned GetActivityTimerElapsedSec() const;
|
||||
@@ -76,6 +80,7 @@ private:
|
||||
boost::timers::portable::microsec_timer m_activityTimer;
|
||||
bool m_activityTimeoutNoticeSent;
|
||||
boost::timers::portable::microsec_timer m_autoDisconnectTimer;
|
||||
boost::shared_ptr<SenderThread> m_sender;
|
||||
|
||||
mutable boost::mutex m_dataMutex;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user