From 493a295f888fb83011809b3bcbcb3edba23d08e7 Mon Sep 17 00:00:00 2001 From: Paul Pacheco Date: Tue, 25 Sep 2018 13:59:57 -0500 Subject: [PATCH] Type safe register/unregister handlers (#44) --- Mirror/Runtime/NetworkClient.cs | 10 ++++++++++ Mirror/Runtime/NetworkServer.cs | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/Mirror/Runtime/NetworkClient.cs b/Mirror/Runtime/NetworkClient.cs index 4d1638d85..f4847721f 100644 --- a/Mirror/Runtime/NetworkClient.cs +++ b/Mirror/Runtime/NetworkClient.cs @@ -303,11 +303,21 @@ public void RegisterHandler(short msgType, NetworkMessageDelegate handler) m_MessageHandlers[msgType] = handler; } + public void RegisterHandler(MsgType msgType, NetworkMessageDelegate handler) + { + RegisterHandler((short)msgType, handler); + } + public void UnregisterHandler(short msgType) { m_MessageHandlers.Remove(msgType); } + public void UnregisterHandler(MsgType msgType) + { + UnregisterHandler((short)msgType); + } + internal static void AddClient(NetworkClient client) { s_Clients.Add(client); diff --git a/Mirror/Runtime/NetworkServer.cs b/Mirror/Runtime/NetworkServer.cs index 1dc48b2ab..e3db7d14e 100644 --- a/Mirror/Runtime/NetworkServer.cs +++ b/Mirror/Runtime/NetworkServer.cs @@ -535,6 +535,11 @@ public static void UnregisterHandler(short msgType) s_MessageHandlers.Remove(msgType); } + public static void UnregisterHandler(MsgType msgType) + { + UnregisterHandler((short)msgType); + } + public static void ClearHandlers() { s_MessageHandlers.Clear();