示例#1
0
        private async Task OnProcess(MessageProcessorHandle handle)
        {
            try {
                var messageType = handle.RequestMessage.GetType();
                if (!registry.TryGet(messageType, out var processFunc))
                {
                    throw new ApplicationException($"No Message Processor was found matching message type '{messageType.Name}'!");
                }

                var result = await processFunc(transceiver, handle.RequestMessage);

                handle.SetResult(result);
            }
            catch (Exception error) {
                handle.SetException(error);
            }
        }