Type safe register/unregister handlers (#44)

This commit is contained in:
Paul Pacheco 2018-09-25 13:59:57 -05:00 committed by vis2k
parent f3886906ef
commit 493a295f88
2 changed files with 15 additions and 0 deletions

View File

@ -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);

View File

@ -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();