ETdoFresh / FishyEOS

A FishNet Transport Library for Unity FishNet.
MIT License
39 stars 16 forks source link

(need ASAP)FishyEOS throws an exception when a remote client quits, and his networked objects dont get destroyed #23

Open superrafyYT opened 2 months ago

superrafyYT commented 2 months ago

here's the full stack trace: NullReferenceException: Object reference not set to an instance of an object FishNet.Transporting.FishyEOSPlugin.ServerPeer.GetConnectionAddress (System.Int32 connectionId) (at Library/PackageCache/com.etdofresh.fishyeos@6a4e06b9b6/Core/ServerPeer.cs:481) FishNet.Transporting.FishyEOSPlugin.FishyEOS.GetConnectionAddress (System.Int32 connectionId) (at Library/PackageCache/com.etdofresh.fishyeos@6a4e06b9b6/FishyEOS.cs:139) FishNet.Connection.NetworkConnection.ToString () (at Assets/FishNet/Runtime/Connection/NetworkConnection.cs:231) System.Text.StringBuilder.AppendFormatHelper (System.IFormatProvider provider, System.String format, System.ParamsArray args) (at <c2a97e0383e8404c9fc0ae19d58f57f1>:0) System.String.FormatHelper (System.IFormatProvider provider, System.String format, System.ParamsArray args) (at <c2a97e0383e8404c9fc0ae19d58f57f1>:0) System.String.Format (System.String format, System.Object arg0) (at <c2a97e0383e8404c9fc0ae19d58f57f1>:0) globalGameManager.onClientStateChanged (FishNet.Connection.NetworkConnection conn, FishNet.Transporting.RemoteConnectionStateArgs args) (at Assets/gameAssets/multiplayerAssets/fishNetScript/gameManager/globalGameManager.cs:467) FishNet.Managing.Server.ServerManager.Transport_OnRemoteConnectionState (FishNet.Transporting.RemoteConnectionStateArgs args) (at Assets/FishNet/Runtime/Managing/Server/ServerManager.cs:550) FishNet.Transporting.FishyEOSPlugin.FishyEOS.HandleRemoteConnectionState (FishNet.Transporting.RemoteConnectionStateArgs connectionStateArgs) (at Library/PackageCache/com.etdofresh.fishyeos@6a4e06b9b6/FishyEOS.cs:202) FishNet.Transporting.FishyEOSPlugin.ServerPeer.OnPeerConnectionClosed (Epic.OnlineServices.P2P.OnRemoteConnectionClosedInfo& data) (at Library/PackageCache/com.etdofresh.fishyeos@6a4e06b9b6/Core/ServerPeer.cs:232) Epic.OnlineServices.P2P.P2PInterface.OnRemoteConnectionClosedCallbackInternalImplementation (Epic.OnlineServices.P2P.OnRemoteConnectionClosedInfoInternal& data) (at Library/PackageCache/com.playeveryware.eos@df7dc4a38cb8/Runtime/EOS_SDK/Generated/P2P/P2PInterface.cs:793) (wrapper native-to-managed) Epic.OnlineServices.P2P.P2PInterface.OnRemoteConnectionClosedCallbackInternalImplementation(Epic.OnlineServices.P2P.OnRemoteConnectionClosedInfoInternal&) Epic.OnlineServices.Platform.PlatformInterface.Tick () (at Library/PackageCache/com.playeveryware.eos@df7dc4a38cb8/Runtime/EOS_SDK/Generated/Platform/PlatformInterface.cs:944) PlayEveryWare.EpicOnlineServices.EOSManager+EOSSingleton.Tick () (at Library/PackageCache/com.playeveryware.eos@df7dc4a38cb8/Runtime/Core/EOSManager.cs:1458) PlayEveryWare.EpicOnlineServices.EOSManager.Update () (at Library/PackageCache/com.playeveryware.eos@df7dc4a38cb8/Runtime/Core/EOSManager.cs:1729) will need this to be fixed ASAP since im gonna use it in production

KatoneVi commented 2 days ago

With the latest version, this should be resolved. ServerPeer.GetConnectionAddress() method was having issues, mainly against the Host Player leaving. Since the ServerPeer _clients never included the HostPlayer's connection, this returns null and crashes. With the latest merge (like 10 minutes ago), this has been resolved.

Furthermore, GetConnectionAddress() now returns the connecting users (clients) ProductUserId, making it easier for you to maintain and identify who is connecting and syncing the EOS side with the FishNet side.

=================== Please note you will get an error in CommonPeers.cs It isn't using the latest EOS approach, so simply replace the "var receivePacketResult..." line with : SocketId socketId = new SocketId(); var receivePacketResult = EOS.GetCachedP2PInterface().ReceivePacket(ref receivePacketOptions, ref remoteUserId, ref socketId, out var channelByte, data, out _);