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)); } }
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); }
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); }
public void Add(ResponseProcessor <T> processor) { this.responseProcessors.Add(processor.MessageId, processor); }