diff --git a/src/net45/WampSharp/WAMP2/V2/Rpc/Dealer/WampRpcOperationCallback.cs b/src/net45/WampSharp/WAMP2/V2/Rpc/Dealer/WampRpcOperationCallback.cs index 9bf6c9d0a..3f8d74eea 100644 --- a/src/net45/WampSharp/WAMP2/V2/Rpc/Dealer/WampRpcOperationCallback.cs +++ b/src/net45/WampSharp/WAMP2/V2/Rpc/Dealer/WampRpcOperationCallback.cs @@ -55,12 +55,14 @@ public void Result(IWampFormatter formatter, YieldOptions de { ResultDetails resultDetails = GetResultDetails(details); this.Result(formatter, resultDetails); + UnregisterConnectionClosedIfNeeded(details); } public void Result(IWampFormatter formatter, YieldOptions details, TMessage[] arguments) { ResultDetails resultDetails = GetResultDetails(details); this.Result(formatter, resultDetails, arguments); + UnregisterConnectionClosedIfNeeded(details); } public void Result(IWampFormatter formatter, YieldOptions details, TMessage[] arguments, @@ -68,21 +70,38 @@ public void Result(IWampFormatter formatter, YieldOptions de { ResultDetails resultDetails = GetResultDetails(details); this.Result(formatter, resultDetails, arguments, argumentsKeywords); + UnregisterConnectionClosedIfNeeded(details); + } + + private void UnregisterConnectionClosedIfNeeded(YieldOptions details) + { + if (details.Progress != true) + { + mMonitor.ConnectionClosed -= OnConnectionClosed; + } } public void Error(IWampFormatter formatter, TResult details, string error) { Caller.CallError(RequestId, details, error); + UnregisterConnectionClosed(); } public void Error(IWampFormatter formatter, TResult details, string error, TResult[] arguments) { Caller.CallError(RequestId, details, error, arguments.Cast().ToArray()); + UnregisterConnectionClosed(); } public void Error(IWampFormatter formatter, TResult details, string error, TResult[] arguments, TResult argumentsKeywords) { Caller.CallError(RequestId, details, error, arguments.Cast().ToArray(), argumentsKeywords); + UnregisterConnectionClosed(); + } + + private void UnregisterConnectionClosed() + { + mMonitor.ConnectionClosed -= OnConnectionClosed; } public event EventHandler Disconnected;