public void Send(Message message, TimeSpan timeout) { if (message == null) { throw new ArgumentNullException(nameof(message)); } WcfClientEventSource.Log.ChannelCalled(GetType().FullName, nameof(Send)); var telemetry = StartSendTelemetry(message, nameof(Send)); try { bool isOneWay = IsOneWay(telemetry); DuplexChannel.Send(message, timeout); if (isOneWay) { // no matching receive StopSendTelemetry(telemetry, null, null, nameof(Send)); } else { correlator.Add(message.Headers.MessageId, telemetry, timeout); } } catch (Exception ex) { StopSendTelemetry(telemetry, null, ex, nameof(Send)); throw; } }
public bool EndWaitForMessage(IAsyncResult result) { if (result == null) { throw new ArgumentNullException(nameof(result)); } WcfClientEventSource.Log.ChannelCalled(GetType().FullName, nameof(EndWaitForMessage)); return(DuplexChannel.EndWaitForMessage(result)); }
public void Send_Uses_Child_Output_Channel_For_Sending() { var outputChannel = A.Fake<IOutputChannel<string>>(); string expectedOutput = "Hi there"; var channel = new DuplexChannel<string>(A.Fake<IInputChannel<string>>(), outputChannel); channel.Send(expectedOutput); A.CallTo(() => outputChannel.Send(expectedOutput)).MustHaveHappened(); }
public void Receive_Uses_Child_Input_Channel_For_Receiving() { var inputChannel = A.Fake<IInputChannel<string>>(); string expectedInput = "Whats up?"; A.CallTo(() => inputChannel.Receive()).Returns(expectedInput); var channel = new DuplexChannel<string>(inputChannel, A.Fake<IOutputChannel<string>>()); string actualInput = channel.Receive(); Assert.That(actualInput, Is.EqualTo(expectedInput)); }
public bool TryReceive(TimeSpan timeout, out Message message) { WcfClientEventSource.Log.ChannelCalled(GetType().FullName, nameof(TryReceive)); bool success = DuplexChannel.TryReceive(timeout, out message); if (success && message != null) { HandleReply(message); } return(success); }
public Message Receive(TimeSpan timeout) { WcfClientEventSource.Log.ChannelCalled(GetType().FullName, nameof(Receive)); var response = DuplexChannel.Receive(timeout); if (response != null) { HandleReply(response); } return(response); }
public IAsyncResult BeginWaitForMessage(TimeSpan timeout, AsyncCallback callback, object state) { WcfClientEventSource.Log.ChannelCalled(GetType().FullName, nameof(BeginWaitForMessage)); return(DuplexChannel.BeginWaitForMessage(timeout, callback, state)); }
public bool WaitForMessage(TimeSpan timeout) { WcfClientEventSource.Log.ChannelCalled(GetType().FullName, nameof(WaitForMessage)); return(DuplexChannel.WaitForMessage(timeout)); }