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