zestylife / EuNet

Peer to peer network solution for multiplayer games.
MIT License
141 stars 26 forks source link

Can not send very long string by ppc call #12

Open playg8 opened 1 year ago

playg8 commented 1 year ago

I used p2p call to send string to other p2p.May be because of the string length is too big, an error occurred. By your design, if the package data is too big, it will be split to small packets and then send to others. But it do not worked,I don't know why. `
public async void CommonRpc2Target(string msg, ushort sessionId) { if (_view.IsMine() == false) return;

    await _actorRpc
        .ToTarget(DeliveryMethod.ReliableUnordered, sessionId)
        .OnCommonRpc(msg);
}

`

Please how can I enable the auto package split.

Error: ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection. System.Buffer.BlockCopy (System.Array src, System.Int32 srcOffset, System.Array dst, System.Int32 dstOffset, System.Int32 count) (at <695d1cc93cca45069c528c15c9fdd749>:0) EuNet.Core.UdpChannel.SendTo (System.Byte[] data, System.Int32 offset, System.Int32 size, EuNet.Core.UdpChannel+SendMode sendMode) (at Assets/Plugins/EuNet/Runtime/EuNet.Core/Channel/UdpChannel.cs:580) EuNet.Core.ReliableSendInfo.TrySend (System.Int64 currentTime, System.Int32 disconnectTimeoutMs, EuNet.Core.UdpChannel udpChannel, EuNet.Core.NetStatistic statistic) (at Assets/Plugins/EuNet/Runtime/EuNet.Core/Channel/ReliableSendInfo.cs:64) EuNet.Core.ReliableChannel.SendPendingPacket () (at Assets/Plugins/EuNet/Runtime/EuNet.Core/Channel/ReliableChannel.cs:201) EuNet.Core.ReliableChannel.Update (System.Int32 elapsedTime) (at Assets/Plugins/EuNet/Runtime/EuNet.Core/Channel/ReliableChannel.cs:128) EuNet.Core.UdpChannel.Update (System.Int32 elapsedTime) (at Assets/Plugins/EuNet/Runtime/EuNet.Core/Channel/UdpChannel.cs:286) EuNet.Client.NetClient.Update (System.Int32 elapsedTime) (at Assets/Plugins/EuNet/Runtime/EuNet.Client/NetClient.cs:288) UnityEngine.Debug:LogException(Exception) EuNet.Unity.NetClientBehaviour:OnError(Exception) (at Assets/Plugins/EuNet/Runtime/EuNet.Unity/NetClientBehaviour.cs:105) EuNet.Client.NetClient:OnError(Exception) (at Assets/Plugins/EuNet/Runtime/EuNet.Client/NetClient.cs:382) EuNet.Client.NetClient:Update(Int32) (at Assets/Plugins/EuNet/Runtime/EuNet.Client/NetClient.cs:340) EuNet.Unity.NetClientP2p:FixedUpdate(Single) (at Assets/Plugins/EuNet/Runtime/EuNet.Unity/Client/NetClientP2p.cs:58) EuNet.Unity.NetClientP2pBehaviour:FixedUpdate() (at Assets/Plugins/EuNet/Runtime/EuNet.Unity/NetClientP2pBehaviour.cs:79)

playg8 commented 1 year ago

Need help, please response me !!!

playg8 commented 1 year ago

May be this function do not work. I have no idea about this.

playg8 commented 1 year ago

I got the reason. It is the XorFilter. After XorFilter encoded the packet, the Size of the packet changed from 1432 to 1433, but I don't know how to fix this.

playg8 commented 1 year ago

When I deleted the XorFilter, another error shot me. Exception: Disconnected due to RUDP timeout EuNet.Client.NetClient.Update (System.Int32 elapsedTime) (at Assets/Plugins/EuNet/Runtime/EuNet.Client/NetClient.cs:289) UnityEngine.Debug:LogException(Exception) EuNet.Unity.NetClientBehaviour:OnError(Exception) (at Assets/Plugins/EuNet/Runtime/EuNet.Unity/NetClientBehaviour.cs:105) EuNet.Client.NetClient:OnError(Exception) (at Assets/Plugins/EuNet/Runtime/EuNet.Client/NetClient.cs:382) EuNet.Client.NetClient:Update(Int32) (at Assets/Plugins/EuNet/Runtime/EuNet.Client/NetClient.cs:340) EuNet.Unity.NetClientP2p:FixedUpdate(Single) (at Assets/Plugins/EuNet/Runtime/EuNet.Unity/Client/NetClientP2p.cs:58) EuNet.Unity.NetClientP2pBehaviour:FixedUpdate() (at Assets/Plugins/EuNet/Runtime/EuNet.Unity/NetClientP2pBehaviour.cs:79)

May be this means long string that larger than mtu can not send to other peer!!!

playg8 commented 1 year ago

After review the code, I am sure there is something wrong with it.