示例#1
0
        private void AddResponseProcessor <T>(ResponseProcessor <T> responseProcessor)
        {
            var typeofResponse = typeof(T);

            if (typeofResponse == Client.stringType)
            {
                this.textResponseManager.Add(responseProcessor as ResponseProcessor <string>);
            }
            else if (typeofResponse == Client.byteArrayType)
            {
                this.binaryResponseManager.Add(responseProcessor as ResponseProcessor <byte[]>);
            }
            else
            {
                throw new InvalidArgumentException(nameof(responseProcessor));
            }
        }
示例#2
0
        internal byte[] SendDataAsync <T>(
            string destination,
            byte[] data,
            SendOptions options,
            Channel <T> responseChannel = null,
            Channel <T> timeoutChannel  = null)
        {
            var payload = MessageFactory.MakeBinaryPayload(data, options.ReplyToId, options.MessageId);

            var messageId = this.SendPayloadAsync(destination, payload, options.IsEncrypted.Value);

            if (messageId != null && options.NoReply != false && responseChannel != null)
            {
                var responseProcessor = new ResponseProcessor <T>(messageId, options.ResponseTimeout, responseChannel, timeoutChannel);
                this.AddResponseProcessor(responseProcessor);
            }

            return(messageId);
        }
示例#3
0
        internal byte[] SendTextManyAsync <T>(
            IEnumerable <string> destinations,
            string text,
            SendOptions options,
            Channel <T> responseChannel = null,
            Channel <T> timeoutChannel  = null)
        {
            var payload = MessageFactory.MakeTextPayload(text, options.ReplyToId, options.MessageId);

            var messageId = this.SendPayloadManyAsync(destinations, payload, options.IsEncrypted.Value);

            if (messageId != null && options.NoReply != false && responseChannel != null)
            {
                var responseProcessor = new ResponseProcessor <T>(messageId, options.ResponseTimeout, responseChannel, timeoutChannel);
                this.AddResponseProcessor(responseProcessor);
            }

            return(messageId);
        }
示例#4
0
 public void Add(ResponseProcessor <T> processor)
 {
     this.responseProcessors.Add(processor.MessageId, processor);
 }