public void ProcessMessages(byte[] data) { var key = (Client.MessageType)data[0]; Console.WriteLine($"Requested: {key}"); if (OnMessage.ContainsKey(key)) { try { var instance = (Client.BaseMessage)Activator.CreateInstance(_serverMessages[key], data); OnMessage[key](this, instance); OnAnyMessage(instance); } catch (Exception e) { Console.WriteLine("Exception: " + e); } } }