예제 #1
0
        public static void Handle(Message message, DofusClient client)
        {
            if (message.IsNull() && !client.IsNull())
            {
                Logger.Init2("[Rcv] Client " + client.SSyncClient.Ip + " send unknown datas, they wont be handled");
                return;
            }
            var handler = Handlers.FirstOrDefault(x => x.Key == message.MessageId);
            if (!handler.Value.IsNull())
            {
                {
                    if (ConfigurationManager.Instance.ShowProtocolMessages)
                        Logger.Write("[Rcv] Message: " + message.ToString(), ConsoleColor.Gray);
                    try
                    {

                        handler.Value.DynamicInvoke(null, message, client);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(string.Format("Unable to handle message {0} {1} : '{2}'", message.ToString(), handler.Value.Method.Name, ex.InnerException.ToString()));
                        ErrorLogsManager.AddLog(ex.InnerException.ToString(), client.SSyncClient.Ip);
                        client.SendRaw("forcedbugreport");
                    }
                }
            }
            else
            {
                if (ConfigurationManager.Instance.ShowProtocolMessages)
                    Logger.Log(string.Format("[Rcv] No Handler: ({0}) {1}", message.MessageId, message.ToString()));
            }
        }
예제 #2
0
        public static void Handle(Message message, DofusClient client)
        {
            if (message.IsNull() && !client.IsNull())
            {
                Logger.Init2("[Rcv] Client " + client.SSyncClient.Ip + " send unknown datas, they wont be handled");
                return;
            }
            var handler = Handlers.FirstOrDefault(x => x.Key == message.MessageId);

            if (!handler.Value.IsNull())
            {
                {
                    if (ConfigurationManager.Instance.ShowProtocolMessages)
                    {
                        Logger.Write("[Rcv] Message: " + message.ToString(), ConsoleColor.Gray);
                    }
                    try
                    {
                        handler.Value.DynamicInvoke(null, message, client);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(string.Format("Unable to handle message {0} {1} : '{2}'", message.ToString(), handler.Value.Method.Name, ex.InnerException.ToString()));
                        ErrorLogsManager.AddLog(ex.InnerException.ToString(), client.SSyncClient.Ip);
                        client.SendRaw("forcedbugreport");
                    }
                }
            }
            else
            {
                if (ConfigurationManager.Instance.ShowProtocolMessages)
                {
                    Logger.Log(string.Format("[Rcv] No Handler: ({0}) {1}", message.MessageId, message.ToString()));
                }
            }
        }