fix: #3787 ThreadedTransport doesn't process Data messages after ClientDisconnect() was called anymore

This commit is contained in:
mischa 2024-10-08 13:44:45 +02:00 committed by mischa
parent 3313fa9c43
commit 8b9578507a

View File

@ -467,12 +467,18 @@ public override void ClientEarlyUpdate()
}
case ClientMainEventType.OnClientReceived:
{
// call original transport event
ConcurrentNetworkWriterPooled writer = (ConcurrentNetworkWriterPooled)elem.param;
OnClientDataReceived?.Invoke(writer, elem.channelId.Value);
// immediately stop processing Data messages after ClientDisconnect() was called.
// ClientDisconnect() sets clientConnected=false, so we can simply check that here.
// fixes: https://github.com/MirrorNetworking/Mirror/issues/3787
if (clientConnected)
{
// call original transport event
ConcurrentNetworkWriterPooled writer = (ConcurrentNetworkWriterPooled)elem.param;
OnClientDataReceived?.Invoke(writer, elem.channelId.Value);
// recycle writer to thread safe pool for reuse
ConcurrentNetworkWriterPool.Return(writer);
// recycle writer to thread safe pool for reuse
ConcurrentNetworkWriterPool.Return(writer);
}
break;
}
case ClientMainEventType.OnClientError: