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 HandledMessage(Action <object, T, Message> callback, T client, Message message) : base(null, client, message, callback) { }