Skip to content

Commit 5455b94

Browse files
committed
Fixing #342?
1 parent 1a5bef8 commit 5455b94

File tree

5 files changed

+17
-32
lines changed

5 files changed

+17
-32
lines changed

src/netstandard/Tests/WampSharp.Tests.Wampv2/Integration/CancelTests.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,6 @@ public void Cancel(InterruptDetails details)
241241
InterruptCalled = true;
242242
}
243243

244-
public bool IsInvocationCompleted
245-
{
246-
get
247-
{
248-
return false;
249-
}
250-
}
251-
252244
public bool InterruptCalled { get; set; }
253245
}
254246
}

src/netstandard/WampSharp/WAMP2/V2/Client/Rpc/WampCallee.cs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
44
using System.Linq;
5+
using System.Reactive;
6+
using System.Reactive.Subjects;
57
using System.Threading.Tasks;
68
using SystemEx;
79
using WampSharp.Core.Listener;
@@ -159,9 +161,9 @@ private IWampRpcOperation TryGetOperation(long registrationId)
159161
return null;
160162
}
161163

162-
private IWampRawRpcOperationRouterCallback GetCallback(long requestId)
164+
private IWampRawRpcOperationRouterCallback GetCallback(long requestId, ISubject<Unit> onCompleted)
163165
{
164-
return new ServerProxyCallback(mProxy, requestId, this);
166+
return new ServerProxyCallback(mProxy, requestId, this, onCompleted);
165167
}
166168

167169
public void Invocation(long requestId, long registrationId, InvocationDetails details)
@@ -200,7 +202,8 @@ private void InvocationPattern(long requestId, long registrationId, InvocationDe
200202

201203
if (operation != null)
202204
{
203-
IWampRawRpcOperationRouterCallback callback = GetCallback(requestId);
205+
ReplaySubject<Unit> onOperationDone = new ReplaySubject<Unit>();
206+
IWampRawRpcOperationRouterCallback callback = GetCallback(requestId, onOperationDone);
204207

205208
InvocationDetails modifiedDetails = new InvocationDetails(details)
206209
{
@@ -215,16 +218,14 @@ private void InvocationPattern(long requestId, long registrationId, InvocationDe
215218

216219
lock (mLock)
217220
{
218-
if (!invocation.IsInvocationCompleted)
219-
{
220-
mRegistrationsToInvocations.Add(registrationId, requestId);
221-
}
221+
mRegistrationsToInvocations.Add(registrationId, requestId);
222222
}
223223

224-
if (invocation.IsInvocationCompleted)
225-
{
226-
CleanupInvocationData(requestId);
227-
}
224+
onOperationDone.Subscribe(x =>
225+
{
226+
this.CleanupInvocationData(requestId);
227+
onOperationDone.Dispose();
228+
});
228229
}
229230
}
230231
}
@@ -361,12 +362,15 @@ private class ServerProxyCallback : IWampRawRpcOperationRouterCallback
361362
{
362363
private readonly IWampServerProxy mProxy;
363364
private readonly WampCallee<TMessage> mParent;
365+
private readonly ISubject<Unit> mOnCompleted;
364366

365-
public ServerProxyCallback(IWampServerProxy proxy, long requestId, WampCallee<TMessage> parent)
367+
public ServerProxyCallback(IWampServerProxy proxy, long requestId, WampCallee<TMessage> parent,
368+
ISubject<Unit> onCompleted)
366369
{
367370
mProxy = proxy;
368371
RequestId = requestId;
369372
mParent = parent;
373+
mOnCompleted = onCompleted;
370374
}
371375

372376
public long RequestId { get; }
@@ -376,6 +380,7 @@ private void Cleanup(YieldOptions yieldOptions = null)
376380
if (yieldOptions?.Progress != true)
377381
{
378382
mParent.CleanupInvocationData(RequestId);
383+
mOnCompleted.OnNext(Unit.Default);
379384
}
380385
}
381386

src/netstandard/WampSharp/WAMP2/V2/Rpc/Callee/CancellationTokenSourceInvocation.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,5 @@ public void Cancel(InterruptDetails details)
2020
{
2121
mCancellationTokenSource.Cancel();
2222
}
23-
24-
public bool IsInvocationCompleted => mTask.IsCompleted;
2523
}
2624
}

src/netstandard/WampSharp/WAMP2/V2/Rpc/Dealer/WampCalleeRpcInvocation.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,5 @@ public void Cancel(InterruptDetails details)
1717
{
1818
Callee.Interrupt(RequestId, details);
1919
}
20-
21-
public bool IsInvocationCompleted
22-
{
23-
get
24-
{
25-
return false;
26-
}
27-
}
2820
}
2921
}

src/netstandard/WampSharp/WAMP2/V2/Rpc/Interfaces/IWampCancellableInvocation.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ namespace WampSharp.V2.Rpc
55
public interface IWampCancellableInvocation
66
{
77
void Cancel(InterruptDetails details);
8-
9-
bool IsInvocationCompleted { get; }
108
}
119
}

0 commit comments

Comments
 (0)