@@ -55,34 +55,53 @@ public void Result<TMessage>(IWampFormatter<TMessage> formatter, YieldOptions de
5555 {
5656 ResultDetails resultDetails = GetResultDetails ( details ) ;
5757 this . Result ( formatter , resultDetails ) ;
58+ UnregisterConnectionClosedIfNeeded ( details ) ;
5859 }
5960
6061 public void Result < TMessage > ( IWampFormatter < TMessage > formatter , YieldOptions details , TMessage [ ] arguments )
6162 {
6263 ResultDetails resultDetails = GetResultDetails ( details ) ;
6364 this . Result ( formatter , resultDetails , arguments ) ;
65+ UnregisterConnectionClosedIfNeeded ( details ) ;
6466 }
6567
6668 public void Result < TMessage > ( IWampFormatter < TMessage > formatter , YieldOptions details , TMessage [ ] arguments ,
6769 IDictionary < string , TMessage > argumentsKeywords )
6870 {
6971 ResultDetails resultDetails = GetResultDetails ( details ) ;
7072 this . Result ( formatter , resultDetails , arguments , argumentsKeywords ) ;
73+ UnregisterConnectionClosedIfNeeded ( details ) ;
74+ }
75+
76+ private void UnregisterConnectionClosedIfNeeded ( YieldOptions details )
77+ {
78+ if ( details . Progress != true )
79+ {
80+ mMonitor . ConnectionClosed -= OnConnectionClosed ;
81+ }
7182 }
7283
7384 public void Error < TResult > ( IWampFormatter < TResult > formatter , TResult details , string error )
7485 {
7586 Caller . CallError ( RequestId , details , error ) ;
87+ UnregisterConnectionClosed ( ) ;
7688 }
7789
7890 public void Error < TResult > ( IWampFormatter < TResult > formatter , TResult details , string error , TResult [ ] arguments )
7991 {
8092 Caller . CallError ( RequestId , details , error , arguments . Cast < object > ( ) . ToArray ( ) ) ;
93+ UnregisterConnectionClosed ( ) ;
8194 }
8295
8396 public void Error < TResult > ( IWampFormatter < TResult > formatter , TResult details , string error , TResult [ ] arguments , TResult argumentsKeywords )
8497 {
8598 Caller . CallError ( RequestId , details , error , arguments . Cast < object > ( ) . ToArray ( ) , argumentsKeywords ) ;
99+ UnregisterConnectionClosed ( ) ;
100+ }
101+
102+ private void UnregisterConnectionClosed ( )
103+ {
104+ mMonitor . ConnectionClosed -= OnConnectionClosed ;
86105 }
87106
88107 public event EventHandler Disconnected ;
0 commit comments