From 0b45bc8049de5feda7017eb37fff0a9280577102 Mon Sep 17 00:00:00 2001 From: Rug Date: Thu, 11 Apr 2024 20:26:23 -0700 Subject: [PATCH] added logging for dropped RPCs and more detailed RPC fail exception logging --- MyceliumNetworkingForCW/MyceliumNetwork.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/MyceliumNetworkingForCW/MyceliumNetwork.cs b/MyceliumNetworkingForCW/MyceliumNetwork.cs index 8aa30ca..0a864b6 100644 --- a/MyceliumNetworkingForCW/MyceliumNetwork.cs +++ b/MyceliumNetworkingForCW/MyceliumNetwork.cs @@ -590,6 +590,9 @@ static void HandleMessage(Message message, CSteamID sender) { var handlers = GetMessageHandlers(message.ModID, message.MethodName); + + bool handled = false; + foreach(var messageHandler in handlers) { if(messageHandler.Mask == message.Mask) @@ -609,8 +612,15 @@ static void HandleMessage(Message message, CSteamID sender) } messageHandler.Method.Invoke(messageHandler.Target, msgParams); + + handled = true; } } + + if(!handled) + { + RugLogger.LogWarning($"Dropped RPC because no registered RPCs were found matching {message.ModID}: {message.MethodName}"); + } } catch(Exception ex) { @@ -625,7 +635,7 @@ static void HandleMessage(Message message, CSteamID sender) destination = destinationEx.Message; } - RugLogger.LogError($"Error executing RPC from {(sender == SteamUser.GetSteamID() ? "local loopback" : sender.ToString())} ({destination}):\n{ex.InnerException} {ex.StackTrace}"); + RugLogger.LogError($"Error executing RPC from {(sender == SteamUser.GetSteamID() ? "local loopback" : sender.ToString())} ({destination}):\n{ex.InnerException}\nFull exception:\n{ex} {ex.StackTrace}"); } }