Renamed WorldTcpSession back to WorldSocket
This commit is contained in:
@@ -400,35 +400,35 @@ void ScriptMgr::OnNetworkStop()
|
||||
FOREACH_SCRIPT(ServerScript)->OnNetworkStop();
|
||||
}
|
||||
|
||||
void ScriptMgr::OnSocketOpen(std::shared_ptr<WorldTcpSession> socket)
|
||||
void ScriptMgr::OnSocketOpen(std::shared_ptr<WorldSocket> socket)
|
||||
{
|
||||
ASSERT(socket);
|
||||
|
||||
FOREACH_SCRIPT(ServerScript)->OnSocketOpen(socket);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnSocketClose(std::shared_ptr<WorldTcpSession> socket, bool wasNew)
|
||||
void ScriptMgr::OnSocketClose(std::shared_ptr<WorldSocket> socket, bool wasNew)
|
||||
{
|
||||
ASSERT(socket);
|
||||
|
||||
FOREACH_SCRIPT(ServerScript)->OnSocketClose(socket, wasNew);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPacketReceive(std::shared_ptr<WorldTcpSession> socket, WorldPacket packet)
|
||||
void ScriptMgr::OnPacketReceive(std::shared_ptr<WorldSocket> socket, WorldPacket packet)
|
||||
{
|
||||
ASSERT(socket);
|
||||
|
||||
FOREACH_SCRIPT(ServerScript)->OnPacketReceive(socket, packet);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPacketSend(std::shared_ptr<WorldTcpSession> socket, WorldPacket packet)
|
||||
void ScriptMgr::OnPacketSend(std::shared_ptr<WorldSocket> socket, WorldPacket packet)
|
||||
{
|
||||
ASSERT(socket);
|
||||
|
||||
FOREACH_SCRIPT(ServerScript)->OnPacketSend(socket, packet);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnUnknownPacketReceive(std::shared_ptr<WorldTcpSession> socket, WorldPacket packet)
|
||||
void ScriptMgr::OnUnknownPacketReceive(std::shared_ptr<WorldSocket> socket, WorldPacket packet)
|
||||
{
|
||||
ASSERT(socket);
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class Transport;
|
||||
class Unit;
|
||||
class Vehicle;
|
||||
class WorldPacket;
|
||||
class WorldTcpSession;
|
||||
class WorldSocket;
|
||||
class WorldObject;
|
||||
|
||||
struct AchievementCriteriaData;
|
||||
@@ -221,23 +221,23 @@ class ServerScript : public ScriptObject
|
||||
virtual void OnNetworkStop() { }
|
||||
|
||||
// Called when a remote socket establishes a connection to the server. Do not store the socket object.
|
||||
virtual void OnSocketOpen(std::shared_ptr<WorldTcpSession> /*socket*/) { }
|
||||
virtual void OnSocketOpen(std::shared_ptr<WorldSocket> /*socket*/) { }
|
||||
|
||||
// Called when a socket is closed. Do not store the socket object, and do not rely on the connection
|
||||
// being open; it is not.
|
||||
virtual void OnSocketClose(std::shared_ptr<WorldTcpSession> /*socket*/, bool /*wasNew*/) { }
|
||||
virtual void OnSocketClose(std::shared_ptr<WorldSocket> /*socket*/, bool /*wasNew*/) { }
|
||||
|
||||
// Called when a packet is sent to a client. The packet object is a copy of the original packet, so reading
|
||||
// and modifying it is safe.
|
||||
virtual void OnPacketSend(std::shared_ptr<WorldTcpSession> /*socket*/, WorldPacket& /*packet*/) { }
|
||||
virtual void OnPacketSend(std::shared_ptr<WorldSocket> /*socket*/, WorldPacket& /*packet*/) { }
|
||||
|
||||
// Called when a (valid) packet is received by a client. The packet object is a copy of the original packet, so
|
||||
// reading and modifying it is safe.
|
||||
virtual void OnPacketReceive(std::shared_ptr<WorldTcpSession> /*socket*/, WorldPacket& /*packet*/) { }
|
||||
virtual void OnPacketReceive(std::shared_ptr<WorldSocket> /*socket*/, WorldPacket& /*packet*/) { }
|
||||
|
||||
// Called when an invalid (unknown opcode) packet is received by a client. The packet is a reference to the orignal
|
||||
// packet; not a copy. This allows you to actually handle unknown packets (for whatever purpose).
|
||||
virtual void OnUnknownPacketReceive(std::shared_ptr<WorldTcpSession> /*socket*/, WorldPacket& /*packet*/) { }
|
||||
virtual void OnUnknownPacketReceive(std::shared_ptr<WorldSocket> /*socket*/, WorldPacket& /*packet*/) { }
|
||||
};
|
||||
|
||||
class WorldScript : public ScriptObject
|
||||
@@ -908,11 +908,11 @@ class ScriptMgr
|
||||
|
||||
void OnNetworkStart();
|
||||
void OnNetworkStop();
|
||||
void OnSocketOpen(std::shared_ptr<WorldTcpSession> socket);
|
||||
void OnSocketClose(std::shared_ptr<WorldTcpSession> socket, bool wasNew);
|
||||
void OnPacketReceive(std::shared_ptr<WorldTcpSession> socket, WorldPacket packet);
|
||||
void OnPacketSend(std::shared_ptr<WorldTcpSession> socket, WorldPacket packet);
|
||||
void OnUnknownPacketReceive(std::shared_ptr<WorldTcpSession> socket, WorldPacket packet);
|
||||
void OnSocketOpen(std::shared_ptr<WorldSocket> socket);
|
||||
void OnSocketClose(std::shared_ptr<WorldSocket> socket, bool wasNew);
|
||||
void OnPacketReceive(std::shared_ptr<WorldSocket> socket, WorldPacket packet);
|
||||
void OnPacketSend(std::shared_ptr<WorldSocket> socket, WorldPacket packet);
|
||||
void OnUnknownPacketReceive(std::shared_ptr<WorldSocket> socket, WorldPacket packet);
|
||||
|
||||
public: /* WorldScript */
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
\ingroup u2w
|
||||
*/
|
||||
|
||||
#include "WorldTcpSession.h"
|
||||
#include "WorldSocket.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, std::shared_ptr<WorldTcpSession> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter):
|
||||
WorldSession::WorldSession(uint32 id, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter):
|
||||
m_muteTime(mute_time),
|
||||
m_timeOutTime(0),
|
||||
AntiDOS(this),
|
||||
|
||||
@@ -46,7 +46,7 @@ class SpellCastTargets;
|
||||
class Unit;
|
||||
class Warden;
|
||||
class WorldPacket;
|
||||
class WorldTcpSession;
|
||||
class WorldSocket;
|
||||
struct AreaTableEntry;
|
||||
struct AuctionEntry;
|
||||
struct DeclinedName;
|
||||
@@ -208,7 +208,7 @@ struct PacketCounter
|
||||
class WorldSession
|
||||
{
|
||||
public:
|
||||
WorldSession(uint32 id, std::shared_ptr<WorldTcpSession> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter);
|
||||
WorldSession(uint32 id, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter);
|
||||
~WorldSession();
|
||||
|
||||
bool PlayerLoading() const { return m_playerLoading; }
|
||||
@@ -981,7 +981,7 @@ class WorldSession
|
||||
|
||||
uint32 m_GUIDLow; // set logined or recently logout player (while m_playerRecentlyLogout set)
|
||||
Player* _player;
|
||||
std::shared_ptr<WorldTcpSession> m_Socket;
|
||||
std::shared_ptr<WorldSocket> m_Socket;
|
||||
std::string m_Address; // Current Remote Address
|
||||
// std::string m_LAddress; // Last Attempted Remote Adress - we can not set attempted ip for a non-existing session!
|
||||
|
||||
|
||||
+10
-10
@@ -19,7 +19,7 @@
|
||||
#include <boost/asio/write.hpp>
|
||||
#include <boost/asio/read_until.hpp>
|
||||
#include <memory>
|
||||
#include "WorldTcpSession.h"
|
||||
#include "WorldSocket.h"
|
||||
#include "ServerPktHeader.h"
|
||||
#include "BigNumber.h"
|
||||
#include "Opcodes.h"
|
||||
@@ -29,18 +29,18 @@
|
||||
using boost::asio::ip::tcp;
|
||||
using boost::asio::streambuf;
|
||||
|
||||
WorldTcpSession::WorldTcpSession(tcp::socket socket)
|
||||
WorldSocket::WorldSocket(tcp::socket socket)
|
||||
: _socket(std::move(socket)), _authSeed(static_cast<uint32>(rand32())), _worldSession(nullptr), _OverSpeedPings(0)
|
||||
{
|
||||
}
|
||||
|
||||
void WorldTcpSession::Start()
|
||||
void WorldSocket::Start()
|
||||
{
|
||||
AsyncReadHeader();
|
||||
HandleSendAuthSession();
|
||||
}
|
||||
|
||||
void WorldTcpSession::HandleSendAuthSession()
|
||||
void WorldSocket::HandleSendAuthSession()
|
||||
{
|
||||
WorldPacket packet(SMSG_AUTH_CHALLENGE, 37);
|
||||
packet << uint32(1); // 1...31
|
||||
@@ -58,7 +58,7 @@ void WorldTcpSession::HandleSendAuthSession()
|
||||
}
|
||||
|
||||
|
||||
void WorldTcpSession::AsyncReadHeader()
|
||||
void WorldSocket::AsyncReadHeader()
|
||||
{
|
||||
auto self(shared_from_this());
|
||||
_socket.async_read_some(boost::asio::buffer(_readBuffer, sizeof(ClientPktHeader)), [this, self](boost::system::error_code error, size_t transferedBytes)
|
||||
@@ -82,7 +82,7 @@ void WorldTcpSession::AsyncReadHeader()
|
||||
});
|
||||
}
|
||||
|
||||
void WorldTcpSession::AsyncReadData(size_t dataSize)
|
||||
void WorldSocket::AsyncReadData(size_t dataSize)
|
||||
{
|
||||
auto self(shared_from_this());
|
||||
_socket.async_read_some(boost::asio::buffer(&_readBuffer[sizeof(ClientPktHeader)], dataSize), [this, dataSize, self](boost::system::error_code error, size_t transferedBytes)
|
||||
@@ -152,7 +152,7 @@ void WorldTcpSession::AsyncReadData(size_t dataSize)
|
||||
});
|
||||
}
|
||||
|
||||
void WorldTcpSession::AsyncWrite(WorldPacket const& packet)
|
||||
void WorldSocket::AsyncWrite(WorldPacket const& packet)
|
||||
{
|
||||
ServerPktHeader header(packet.size() + 2, packet.GetOpcode());
|
||||
_authCrypt.EncryptSend((uint8*)header.header, header.getHeaderLength());
|
||||
@@ -177,7 +177,7 @@ void WorldTcpSession::AsyncWrite(WorldPacket const& packet)
|
||||
});
|
||||
}
|
||||
|
||||
void WorldTcpSession::HandleAuthSession(WorldPacket& recvPacket)
|
||||
void WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
|
||||
{
|
||||
uint8 digest[20];
|
||||
uint32 clientSeed;
|
||||
@@ -404,7 +404,7 @@ void WorldTcpSession::HandleAuthSession(WorldPacket& recvPacket)
|
||||
sWorld->AddSession(_worldSession);
|
||||
}
|
||||
|
||||
void WorldTcpSession::SendAuthResponseError(uint8 code)
|
||||
void WorldSocket::SendAuthResponseError(uint8 code)
|
||||
{
|
||||
WorldPacket packet(SMSG_AUTH_RESPONSE, 1);
|
||||
packet << uint8(code);
|
||||
@@ -412,7 +412,7 @@ void WorldTcpSession::SendAuthResponseError(uint8 code)
|
||||
AsyncWrite(packet);
|
||||
}
|
||||
|
||||
void WorldTcpSession::HandlePing(WorldPacket& recvPacket)
|
||||
void WorldSocket::HandlePing(WorldPacket& recvPacket)
|
||||
{
|
||||
uint32 ping;
|
||||
uint32 latency;
|
||||
@@ -41,13 +41,13 @@ struct ClientPktHeader
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
class WorldTcpSession : public std::enable_shared_from_this<WorldTcpSession>
|
||||
class WorldSocket : public std::enable_shared_from_this<WorldSocket>
|
||||
{
|
||||
public:
|
||||
WorldTcpSession(tcp::socket socket);
|
||||
WorldSocket(tcp::socket socket);
|
||||
|
||||
WorldTcpSession(WorldTcpSession const& right) = delete;
|
||||
WorldTcpSession& operator=(WorldTcpSession const& right) = delete;
|
||||
WorldSocket(WorldSocket const& right) = delete;
|
||||
WorldSocket& operator=(WorldSocket const& right) = delete;
|
||||
|
||||
void Start();
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#include "TCSoap.h"
|
||||
#include "CliRunnable.h"
|
||||
#include "SystemConfig.h"
|
||||
#include "WorldTcpSession.h"
|
||||
#include "WorldSocket.h"
|
||||
|
||||
#define TRINITY_CORE_CONFIG "worldserver.conf"
|
||||
#define WORLD_SLEEP_CONST 50
|
||||
@@ -230,7 +230,7 @@ extern int main(int argc, char** argv)
|
||||
std::string worldListener = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");
|
||||
bool tcpNoDelay = sConfigMgr->GetBoolDefault("Network.TcpNodelay", true);
|
||||
|
||||
AsyncAcceptor<WorldTcpSession> worldAcceptor(_ioService, worldListener, worldPort, tcpNoDelay);
|
||||
AsyncAcceptor<WorldSocket> worldAcceptor(_ioService, worldListener, worldPort, tcpNoDelay);
|
||||
|
||||
sScriptMgr->OnStartup();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user