This example is well and good, but some explanations to it would be very helpful. This code is pretty inexplicable.
Specifically:
1. Why is an "IDuplexClient" interface specified and never implemented? And if it isn't implemented, why is it there?
2. What is happening in the ReceiveComplete method?
a. This comment:
// Server closed its output session, can close client channel,
// or continue sending messages to start a new session.
What does it mean that the server closed its output session? Why is my received message null? What does it mean to "continue sending messages to start a new session"? Does it mean going back to the start, instantiation a new factory, channel, sending the message, etc.?
b. And why, when I my received message is not null, do I call ReceiveLoop again? Haven't I already received the message I was polling for, even though it wasn't the response
I was hoping for?
c. The catch for the
CommunicationObjectFaultedException
seems to leave out a variety of situations that I have run into in which this exception is thrown not because of a time-out, as well as all the issues revolving around extending the timeout beyond 10 mins, which seems to be particularly difficult to do.
3. I think it would be helpful to add links for those who are not
totally fluent in all the asynchronous logic happening here (like the
repeated checks for "CompletedSynchronously").