public DisptachingMessage(IMessage message, DisptachingMessageStream parentMessageStream, IEnumerable <IMessageHandlerProxy> handlers, ITypeCodeProvider typeCodeProvider) { Message = message; _parentMessageStream = parentMessageStream; _handlerDict = new ConcurrentDictionary <int, IMessageHandlerProxy>(); handlers.ForEach(x => _handlerDict.TryAdd(typeCodeProvider.GetTypeCode(x.GetInnerHandler().GetType()), x)); }
private Task <AsyncTaskResult> DispatchMessageStream(DisptachingMessageStream messageStream) { var message = messageStream.DequeueMessage(); if (message == null) { return(Task.FromResult <AsyncTaskResult>(AsyncTaskResult.Success)); } DispatchMessage(message, messageStream); return(messageStream.Task); }
private void DispatchMessage(IMessage message, DisptachingMessageStream messageStream) { var handlers = _handlerProvider.GetHandlers(message.GetType()); if (!handlers.Any()) { messageStream.OnMessageHandled(message); return; } var dispatchingMessage = new DisptachingMessage(message, messageStream, handlers, _typeCodeProvider); foreach (var handler in handlers) { DispatchMessageToHandlerAsync(dispatchingMessage, handler, 0); } }
private void DispatchMessage(IMessage message, DisptachingMessageStream messageStream) { var handlers = _handlerProvider.GetHandlers(message.GetType()); if (!handlers.Any()) { messageStream.OnMessageHandled(message); return; } var dispatchingMessage = new DisptachingMessage(message, messageStream, handlers, _typeCodeProvider); foreach (var handler in handlers) { DispatchMessageToHandlerAsync(dispatchingMessage, handler, 0); } }
public Task <AsyncTaskResult> DispatchMessagesAsync(IEnumerable <IMessage> messages) { var messageStream = new DisptachingMessageStream(messages); foreach (var message in messages) { var handlers = _handlerProvider.GetHandlers(message.GetType()); if (!handlers.Any()) { messageStream.RemoveHandledMessage(message.Id); continue; } var dispatchingMessage = new DisptachingMessage(message, messageStream, handlers); foreach (var handler in handlers) { DispatchMessageToHandlerAsync(dispatchingMessage, handler, 0); } } return(messageStream.Task); }
private Task<AsyncTaskResult> DispatchMessageStream(DisptachingMessageStream messageStream) { var message = messageStream.DequeueMessage(); if (message == null) { return Task.FromResult<AsyncTaskResult>(AsyncTaskResult.Success); } DispatchMessage(message, messageStream); return messageStream.Task; }
public DisptachingMessage(IMessage message, DisptachingMessageStream parentMessageStream, IEnumerable<IMessageHandlerProxy> handlers, ITypeCodeProvider typeCodeProvider) { Message = message; _parentMessageStream = parentMessageStream; _handlerDict = new ConcurrentDictionary<int, IMessageHandlerProxy>(); handlers.ForEach(x => _handlerDict.TryAdd(typeCodeProvider.GetTypeCode(x.GetInnerHandler().GetType()), x)); }