Core/World: Move linking instance socket to WorldSession
Port From (https://github.com/TrinityCore/TrinityCore/commit/cb837ce926d6a8c13d5f74faea246fea19db91d0)
This commit is contained in:
@@ -373,6 +373,23 @@ namespace Game
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AddInstanceConnection(WorldSession session, WorldSocket socket, ConnectToKey key)
|
||||||
|
{
|
||||||
|
if (socket == null || !socket.IsOpen())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (session == null || session.GetConnectToInstanceKey() != key.Raw)
|
||||||
|
{
|
||||||
|
socket.SendAuthResponseError(BattlenetRpcErrorCode.TimedOut);
|
||||||
|
socket.CloseSocket();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.SetWorldSession(session);
|
||||||
|
session.m_Socket[(int)ConnectionType.Instance] = socket;
|
||||||
|
session.HandleContinuePlayerLogin();
|
||||||
|
}
|
||||||
|
|
||||||
public void QueuePacket(WorldPacket packet)
|
public void QueuePacket(WorldPacket packet)
|
||||||
{
|
{
|
||||||
_recvQueue.Enqueue(packet);
|
_recvQueue.Enqueue(packet);
|
||||||
@@ -411,8 +428,6 @@ namespace Game
|
|||||||
m_Socket[(int)conIdx].SendPacket(packet);
|
m_Socket[(int)conIdx].SendPacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddInstanceConnection(WorldSocket sock) { m_Socket[(int)ConnectionType.Instance] = sock; }
|
|
||||||
|
|
||||||
public void KickPlayer(string reason)
|
public void KickPlayer(string reason)
|
||||||
{
|
{
|
||||||
Log.outInfo(LogFilter.Network, $"Account: {GetAccountId()} Character: '{(_player != null ? _player.GetName() : "<none>")}' {(_player != null ? _player.GetGUID() : "")} kicked with reason: {reason}");
|
Log.outInfo(LogFilter.Network, $"Account: {GetAccountId()} Character: '{(_player != null ? _player.GetName() : "<none>")}' {(_player != null ? _player.GetGUID() : "")} kicked with reason: {reason}");
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ namespace Game
|
|||||||
|
|
||||||
public void AddInstanceSocket(WorldSocket sock, ulong connectToKey)
|
public void AddInstanceSocket(WorldSocket sock, ulong connectToKey)
|
||||||
{
|
{
|
||||||
_linkSocketQueue.Enqueue(Tuple.Create(sock, connectToKey));
|
_linkSocketQueue.Enqueue((sock, connectToKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddSession_(WorldSession s)
|
void AddSession_(WorldSession s)
|
||||||
@@ -261,27 +261,6 @@ namespace Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessLinkInstanceSocket(Tuple<WorldSocket, ulong> linkInfo)
|
|
||||||
{
|
|
||||||
if (!linkInfo.Item1.IsOpen())
|
|
||||||
return;
|
|
||||||
|
|
||||||
ConnectToKey key = new();
|
|
||||||
key.Raw = linkInfo.Item2;
|
|
||||||
|
|
||||||
WorldSession session = FindSession(key.AccountId);
|
|
||||||
if (session == null || session.GetConnectToInstanceKey() != linkInfo.Item2)
|
|
||||||
{
|
|
||||||
linkInfo.Item1.SendAuthResponseError(BattlenetRpcErrorCode.TimedOut);
|
|
||||||
linkInfo.Item1.CloseSocket();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
linkInfo.Item1.SetWorldSession(session);
|
|
||||||
session.AddInstanceConnection(linkInfo.Item1);
|
|
||||||
session.HandleContinuePlayerLogin();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HasRecentlyDisconnected(WorldSession session)
|
bool HasRecentlyDisconnected(WorldSession session)
|
||||||
{
|
{
|
||||||
if (session == null)
|
if (session == null)
|
||||||
@@ -1980,15 +1959,17 @@ namespace Game
|
|||||||
|
|
||||||
public void UpdateSessions(uint diff)
|
public void UpdateSessions(uint diff)
|
||||||
{
|
{
|
||||||
Tuple<WorldSocket, ulong> linkInfo;
|
|
||||||
while (_linkSocketQueue.TryDequeue(out linkInfo))
|
|
||||||
ProcessLinkInstanceSocket(linkInfo);
|
|
||||||
|
|
||||||
// Add new sessions
|
// Add new sessions
|
||||||
WorldSession sess;
|
WorldSession sess;
|
||||||
while (addSessQueue.TryDequeue(out sess))
|
while (addSessQueue.TryDequeue(out sess))
|
||||||
AddSession_(sess);
|
AddSession_(sess);
|
||||||
|
|
||||||
|
while (_linkSocketQueue.TryDequeue(out (WorldSocket, ulong) linkInfo))
|
||||||
|
{
|
||||||
|
ConnectToKey key = new() { Raw = linkInfo.Item2 };
|
||||||
|
WorldSession.AddInstanceConnection(FindSession(key.AccountId), linkInfo.Item1, key);
|
||||||
|
}
|
||||||
|
|
||||||
// Then send an update signal to remaining ones
|
// Then send an update signal to remaining ones
|
||||||
foreach (var pair in m_sessions)
|
foreach (var pair in m_sessions)
|
||||||
{
|
{
|
||||||
@@ -2629,7 +2610,7 @@ namespace Game
|
|||||||
List<WorldSession> m_QueuedPlayer = new();
|
List<WorldSession> m_QueuedPlayer = new();
|
||||||
ConcurrentQueue<WorldSession> addSessQueue = new();
|
ConcurrentQueue<WorldSession> addSessQueue = new();
|
||||||
|
|
||||||
ConcurrentQueue<Tuple<WorldSocket, ulong>> _linkSocketQueue = new();
|
ConcurrentQueue<(WorldSocket, ulong)> _linkSocketQueue = new();
|
||||||
|
|
||||||
AsyncCallbackProcessor<QueryCallback> _queryProcessor = new();
|
AsyncCallbackProcessor<QueryCallback> _queryProcessor = new();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user