Skip to content

Commit 09ebb6d

Browse files
committed
Fixed local read issue on host RPCs
1 parent 4d7bcb4 commit 09ebb6d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,11 @@ internal void SendServerRPCPerformance(ulong hash, Stream messageStream)
571571

572572
if (isHost)
573573
{
574-
InvokeServerRPCLocal(hash, NetworkingManager.singleton.LocalClientId, messageStream);
574+
using (PooledBitStream localStream = PooledBitStream.Get())
575+
{
576+
localStream.CopyFrom(messageStream);
577+
InvokeServerRPCLocal(hash, NetworkingManager.singleton.LocalClientId, localStream);
578+
}
575579
}
576580

577581
InternalMessageHandler.Send(NetworkingManager.singleton.NetworkConfig.NetworkTransport.ServerNetId, "MLAPI_SERVER_RPC", "MLAPI_DEFAULT_MESSAGE", stream);
@@ -616,7 +620,11 @@ internal void SendClientRPCPerformance(ulong hash, List<uint> clientIds, Stream
616620
{
617621
if (isHost && clientIds[i] == NetworkingManager.singleton.LocalClientId)
618622
{
619-
InvokeClientRPCLocal(hash, NetworkingManager.singleton.LocalClientId, messageStream);
623+
using (PooledBitStream localStream = PooledBitStream.Get())
624+
{
625+
localStream.CopyFrom(messageStream);
626+
InvokeClientRPCLocal(hash, NetworkingManager.singleton.LocalClientId, localStream);
627+
}
620628
}
621629
else
622630
{
@@ -647,7 +655,11 @@ internal void SendClientRPCPerformance(ulong hash, uint clientId, Stream message
647655

648656
if (isHost && clientId == NetworkingManager.singleton.LocalClientId)
649657
{
650-
InvokeClientRPCLocal(hash, NetworkingManager.singleton.LocalClientId, messageStream);
658+
using (PooledBitStream localStream = PooledBitStream.Get())
659+
{
660+
localStream.CopyFrom(messageStream);
661+
InvokeClientRPCLocal(hash, NetworkingManager.singleton.LocalClientId, localStream);
662+
}
651663
}
652664
else
653665
{

0 commit comments

Comments
 (0)