public override async Task TestMethod(Empty request, IServerStreamWriter responseStream, ServerCallContext context)
{
logger.LogInfo($"request was registered!");
// Completing the method means disconnecting the stream by server side.
// So just waiting the client to disconnect.
var cts = new CancellationTokenSource();
context.CancellationToken.Register(() =>
{
// This code was not called when the client has been killed.
logger.LogInfo($"Subscription finished");
cts.Cancel();
});
await AwaitCancellation(cts.Token);
}
private static Task AwaitCancellation(CancellationToken token)
{
var completion = new TaskCompletionSource
Here is my code:
public override async Task TestMethod(Empty request, IServerStreamWriter responseStream, ServerCallContext context)
{
logger.LogInfo($"request was registered!");
}
private static Task AwaitCancellation(CancellationToken token) { var completion = new TaskCompletionSource