Skip to content

Commit

Permalink
Working on #342 again
Browse files Browse the repository at this point in the history
  • Loading branch information
darkl committed Jun 9, 2022
1 parent 8930fe6 commit 269d10f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/netstandard/WampSharp/WAMP2/V2/Client/Rpc/WampCallee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,15 @@ private void InvocationPattern(long requestId, long registrationId, InvocationDe

lock (mLock)
{
mRegistrationsToInvocations.Add(registrationId, requestId);
if (!invocation.IsInvocationCompleted)
{
mRegistrationsToInvocations.Add(registrationId, requestId);
}
}

if (invocation.IsInvocationCompleted)
{
CleanupInvocationData(requestId);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ protected override IWampCancellableInvocation InnerInvoke<TMessage>(IWampRawRpcO
{
CancellationTokenSourceInvocation result = null;
CancellationToken token = CancellationToken.None;
CancellationTokenSource cancellationTokenSource = null;

if (SupportsCancellation)
{
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
result = new CancellationTokenSourceInvocation(cancellationTokenSource);
cancellationTokenSource = new CancellationTokenSource();
token = cancellationTokenSource.Token;
}

Expand All @@ -37,7 +37,12 @@ protected override IWampCancellableInvocation InnerInvoke<TMessage>(IWampRawRpcO
arguments,
argumentsKeywords,
token);


if (SupportsCancellation)
{
result = new CancellationTokenSourceInvocation(task ,cancellationTokenSource);
}

return result;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
using System.Threading;
using System.Threading.Tasks;
using WampSharp.V2.Core.Contracts;

namespace WampSharp.V2.Rpc
{
internal class CancellationTokenSourceInvocation : IWampCancellableInvocation
{
private readonly Task mTask;
private readonly CancellationTokenSource mCancellationTokenSource;

public CancellationTokenSourceInvocation(CancellationTokenSource cancellationTokenSource)
public CancellationTokenSourceInvocation(Task task,
CancellationTokenSource cancellationTokenSource)
{
mTask = task;
mCancellationTokenSource = cancellationTokenSource;
}

public void Cancel(InterruptDetails details)
{
mCancellationTokenSource.Cancel();
}

public bool IsInvocationCompleted => mTask.IsCompleted;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,13 @@ public void Cancel(InterruptDetails details)
{
Callee.Interrupt(RequestId, details);
}

public bool IsInvocationCompleted
{
get
{
return false;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ namespace WampSharp.V2.Rpc
public interface IWampCancellableInvocation
{
void Cancel(InterruptDetails details);

bool IsInvocationCompleted { get; }
}
}

0 comments on commit 269d10f

Please sign in to comment.