Facepunch Transport fix (#116)
* fixed 'Received a message that claimed a size larger than the packet, ending early' warning which caused clients to not load in properly * removed unnecessary unsafe buffer copy from Transport.Send override
This commit is contained in:
Родитель
b08829c71c
Коммит
93febe1faa
|
@ -134,18 +134,14 @@ namespace Netcode.Transports.Facepunch
|
|||
}
|
||||
}
|
||||
|
||||
public override unsafe void Send(ulong clientId, ArraySegment<byte> data, NetworkDelivery delivery)
|
||||
public override void Send(ulong clientId, ArraySegment<byte> data, NetworkDelivery delivery)
|
||||
{
|
||||
var sendType = NetworkDeliveryToSendType(delivery);
|
||||
|
||||
byte* buffer = stackalloc byte[data.Count];
|
||||
fixed (byte* pointer = data.Array)
|
||||
Buffer.MemoryCopy(pointer + data.Offset, buffer, data.Count, data.Count);
|
||||
|
||||
if (clientId == ServerClientId)
|
||||
connectionManager.Connection.SendMessage((IntPtr)buffer, data.Count , sendType);
|
||||
connectionManager.Connection.SendMessage(data.Array, data.Offset, data.Count, sendType);
|
||||
else if (connectedClients.TryGetValue(clientId, out Client user))
|
||||
user.connection.SendMessage((IntPtr)buffer, data.Count, sendType);
|
||||
user.connection.SendMessage(data.Array, data.Offset, data.Count, sendType);
|
||||
else if (LogLevel <= LogLevel.Normal)
|
||||
Debug.LogWarning($"[{nameof(FacepunchTransport)}] - Failed to send packet to remote client with ID {clientId}, client not connected.");
|
||||
}
|
||||
|
@ -211,7 +207,7 @@ namespace Netcode.Transports.Facepunch
|
|||
{
|
||||
byte[] payload = new byte[size];
|
||||
Marshal.Copy(data, payload, 0, size);
|
||||
InvokeOnTransportEvent(NetworkEvent.Data, ServerClientId, new ArraySegment<byte>(payload, 0, size - 1), Time.realtimeSinceStartup);
|
||||
InvokeOnTransportEvent(NetworkEvent.Data, ServerClientId, new ArraySegment<byte>(payload, 0, size), Time.realtimeSinceStartup);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Загрузка…
Ссылка в новой задаче