예제 #1
0
        public override void Dispatch(FakeClient client, Message message)
        {
            List <MessageHandler> handlers;

            if (m_handlers.TryGetValue(message.MessageId, out handlers))
            {
                try
                {
                    foreach (var handler in handlers)
                    {
                        if (!handler.Container.CanHandleMessage(client, message.MessageId))
                        {
                            m_logger.Warn(client + " tried to send " + message + " but predicate didn't success");
                            return;
                        }

                        m_taskPool.AddMessage(new BenchmarkingMessage(new HandledMessage <FakeClient>(handler.Action, client, message)));
                    }
                }
                catch (Exception ex)
                {
                    m_logger.Error(string.Format("[Handler : {0}] Force disconnection of client {1} : {2}", message, client, ex));
                    client.Disconnect();
                }
            }
        }
예제 #2
0
        public override void Dispatch(BaseClient client, UiC.Network.Protocol.Message message)
        {
            List <MessageHandler> handlers;

            if (m_handlers.TryGetValue(message.MessageId, out handlers))
            {
                try
                {
                    foreach (var handler in handlers)
                    {
                        //logger.Info($"TaskPool: {m_taskPool.MessageQueue.Count} / { m_taskPoolSecondary.MessageQueue.Count}");

                        if (m_taskPool.MessageQueue.Count < m_taskPoolSecondary.MessageQueue.Count)
                        {
                            m_taskPool.AddMessage(new SelfRunningMessage(new HandledMessage <BaseClient>(handler.Action, client, message)));
                        }
                        else
                        {
                            m_taskPoolSecondary.AddMessage(new SelfRunningMessage(new HandledMessage <BaseClient>(handler.Action, client, message)));
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Info(string.Format("[Handler : {0}] Force disconnection of client {1} : {2}", message, client, ex));
                    client.Disconnect();
                }
            }
        }
예제 #3
0
        public static void SendWebhook(Webhook webhook)
        {
            Initialize();

            if (webhook.Embeds.Count > 0)
            {
                Log.Write(LogLevel.Info, "Send Webhook: " + webhook.Embeds[0].Description);
            }

            m_taskpool.AddMessage(webhook.Send);
        }
예제 #4
0
        public override void Dispatch(NetworkClient client, Protocol.Message message)
        {
            List <MessageHandler> handlers;

            if (m_handlers.TryGetValue(message.MessageId, out handlers))
            {
                try
                {
                    foreach (var handler in handlers)
                    {
                        m_taskPool.AddMessage(new SelfRunningMessage(new HandledMessage <NetworkClient>(handler.Action, client, message)));
                    }
                }
                catch (Exception ex)
                {
                    Log.Write(LogLevel.Info, string.Format("[Handler : {0}] Force disconnection of client {1} : {2}", message, client, ex));
                    client.Disconnect();
                }
            }
        }