Some groundwork for replacing the ACE based WorldSocket handling
This commit is contained in:
1 parent
021e18d152
commit
7befb26625
13 files changed
+579
-1819
No files matched your search
@@ -20,7 +20,7 @@
|
||||
\ingroup u2w
|
||||
*/
|
||||
|
||||
#include "WorldSocket.h" // must be first to make ACE happy with ACE includes in it
|
||||
#include "WorldTcpSession.h"
|
||||
#include "Config.h"
|
||||
#include "Common.h"
|
||||
#include "DatabaseEnv.h"
|
||||
@@ -97,7 +97,7 @@ bool WorldSessionFilter::Process(WorldPacket* packet)
|
||||
}
|
||||
|
||||
/// WorldSession constructor
|
||||
WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter):
|
||||
WorldSession::WorldSession(uint32 id, WorldTcpSession* sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter):
|
||||
m_muteTime(mute_time),
|
||||
m_timeOutTime(0),
|
||||
AntiDOS(this),
|
||||
@@ -130,8 +130,7 @@ WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8
|
||||
|
||||
if (sock)
|
||||
{
|
||||
m_Address = sock->GetRemoteAddress();
|
||||
sock->AddReference();
|
||||
m_Address = sock->GetRemoteIpAddress();
|
||||
ResetTimeOutTime();
|
||||
LoginDatabase.PExecute("UPDATE account SET online = 1 WHERE id = %u;", GetAccountId()); // One-time query
|
||||
}
|
||||
@@ -150,7 +149,6 @@ WorldSession::~WorldSession()
|
||||
if (m_Socket)
|
||||
{
|
||||
m_Socket->CloseSocket();
|
||||
m_Socket->RemoveReference();
|
||||
m_Socket = NULL;
|
||||
}
|
||||
|
||||
@@ -227,8 +225,7 @@ void WorldSession::SendPacket(WorldPacket const* packet)
|
||||
}
|
||||
#endif // !TRINITY_DEBUG
|
||||
|
||||
if (m_Socket->SendPacket(*packet) == -1)
|
||||
m_Socket->CloseSocket();
|
||||
m_Socket->AsyncWrite(*packet);
|
||||
}
|
||||
|
||||
/// Add an incoming packet to the queue
|
||||
@@ -281,9 +278,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
|
||||
uint32 processedPackets = 0;
|
||||
time_t currentTime = time(NULL);
|
||||
|
||||
while (m_Socket && !m_Socket->IsClosed() &&
|
||||
!_recvQueue.empty() && _recvQueue.peek(true) != firstDelayedPacket &&
|
||||
_recvQueue.next(packet, updater))
|
||||
while (m_Socket && !_recvQueue.empty() && _recvQueue.peek(true) != firstDelayedPacket && _recvQueue.next(packet, updater))
|
||||
{
|
||||
if (!AntiDOS.EvaluateOpcode(*packet, currentTime))
|
||||
{
|
||||
@@ -402,7 +397,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_Socket && !m_Socket->IsClosed() && _warden)
|
||||
if (m_Socket && m_Socket->IsOpen() && _warden)
|
||||
_warden->Update();
|
||||
|
||||
ProcessQueryCallbacks();
|
||||
@@ -420,12 +415,11 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
|
||||
_warden->Update();
|
||||
|
||||
///- Cleanup socket pointer if need
|
||||
if (m_Socket && m_Socket->IsClosed())
|
||||
if (m_Socket && !m_Socket->IsOpen())
|
||||
{
|
||||
expireTime -= expireTime > diff ? diff : expireTime;
|
||||
if (expireTime < diff || forceExit)
|
||||
{
|
||||
m_Socket->RemoveReference();
|
||||
m_Socket = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user