From 791e76601b892faf1295633539c31a27591c63b9 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Mon, 24 Jan 2022 02:14:53 -0800 Subject: [PATCH] fizzy OnTransportError --- FizzyFacepunch/FizzyFacepunch.cs | 2 ++ FizzyFacepunch/NextClient.cs | 2 ++ FizzyFacepunch/NextServer.cs | 2 ++ QSB/QSBNetworkManager.cs | 6 ++++-- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/FizzyFacepunch/FizzyFacepunch.cs b/FizzyFacepunch/FizzyFacepunch.cs index eed403d0..e6d63ab3 100644 --- a/FizzyFacepunch/FizzyFacepunch.cs +++ b/FizzyFacepunch/FizzyFacepunch.cs @@ -34,6 +34,8 @@ namespace Mirror.FizzySteam [Tooltip("This will display your Steam User ID when you start or connect to a server.")] public ulong SteamUserID; + public Action OnTransportError; + private void Awake() { const string fileName = "steam_appid.txt"; diff --git a/FizzyFacepunch/NextClient.cs b/FizzyFacepunch/NextClient.cs index cd36f0ab..fe168b5f 100644 --- a/FizzyFacepunch/NextClient.cs +++ b/FizzyFacepunch/NextClient.cs @@ -18,6 +18,7 @@ namespace Mirror.FizzySteam private event Action OnReceivedData; private event Action OnConnected; private event Action OnDisconnected; + private event Action OnTransportError; private CancellationTokenSource cancelToken; private TaskCompletionSource connectedComplete; @@ -39,6 +40,7 @@ namespace Mirror.FizzySteam c.OnConnected += () => transport.OnClientConnected.Invoke(); c.OnDisconnected += () => transport.OnClientDisconnected.Invoke(); c.OnReceivedData += (data, ch) => transport.OnClientDataReceived.Invoke(new ArraySegment(data), ch); + c.OnTransportError = transport.OnTransportError; if (SteamClient.IsValid) { diff --git a/FizzyFacepunch/NextServer.cs b/FizzyFacepunch/NextServer.cs index 07b2dcac..0a43863f 100644 --- a/FizzyFacepunch/NextServer.cs +++ b/FizzyFacepunch/NextServer.cs @@ -11,6 +11,7 @@ namespace Mirror.FizzySteam private event Action OnReceivedData; private event Action OnDisconnected; private event Action OnReceivedError; + private event Action OnTransportError; private BidirectionalDictionary connToMirrorID; private BidirectionalDictionary steamIDToMirrorID; @@ -36,6 +37,7 @@ namespace Mirror.FizzySteam s.OnDisconnected += (id) => transport.OnServerDisconnected.Invoke(id); s.OnReceivedData += (id, data, ch) => transport.OnServerDataReceived.Invoke(id, new ArraySegment(data), ch); s.OnReceivedError += (id, exception) => transport.OnServerError.Invoke(id, exception); + s.OnTransportError = transport.OnTransportError; if (!SteamClient.IsValid) { diff --git a/QSB/QSBNetworkManager.cs b/QSB/QSBNetworkManager.cs index 94827514..ef35b775 100644 --- a/QSB/QSBNetworkManager.cs +++ b/QSB/QSBNetworkManager.cs @@ -51,6 +51,7 @@ namespace QSB private string _lastTransportError; internal bool _intentionalDisconnect; private const string _kcpDisconnectMessage = "KCP: received disconnect message"; + private const int _defaultSteamAppID = 753640; public override void Awake() { @@ -72,8 +73,9 @@ namespace QSB { var fizzy = gameObject.AddComponent(); fizzy.SteamAppID = QSBCore.OverrideAppId == -1 - ? "753640" - : $"{QSBCore.OverrideAppId}"; + ? _defaultSteamAppID.ToString() + : QSBCore.OverrideAppId.ToString(); + fizzy.OnTransportError = error => _lastTransportError = error; transport = fizzy; }