When writing an
IDuplexSessionChannel, one of the pieces that needs to be implemented is (as you might expect)
IDuplexSession has one additional requirement on top of ISession, and that is the ability to perform a “half-close”. Semantically this is the same as Shutdown(Send) in sockets-speak.
When you call
.CloseOutputSession(), this signals to the other side of the session that it should return null from outstanding and subsequent calls to
Receive(). CloseOutputSession() is also idempotent (just like
CloseOutputSession() is also a little tricky, because it’s a session method that can interact with the owning
IDuplexSessionChannel that owns the session. In particular, if your session lifetime is coupled with your channel lifetime (like it is for TCP and RM and Security):
- If CloseOutputSession() is called before channel.Close(), channel.Close() should wait for CloseOutputSession() to finish.
- If the channel is in the Created or Opening state, CloseOutputSession() should
- If the channel is in the Faulted state, CloseOutputSession() should
- The channel should fault if CloseOutputSession throws.
- channel.Close() should call CloseOutputSession() and then verify that Receive() returns
null(i.e. CloseOutputSession was called from the other side of the session).