public override Task <Empty> Unsubscribe(Empty request, ServerCallContext context) { var contextLogin = context.GetLogin(); _grpcObservable.Unregister(contextLogin); return(Task.FromResult(new Empty())); }
public override async Task Notify(Empty request, IServerStreamWriter <proto.EventMessage> responseStream, ServerCallContext context) { var contextLogin = context.GetLogin(); var subscriber = new GrpcNotificationObserver(contextLogin, responseStream); _grpcObservable.Register(subscriber); while (!_grpcObservable.HasUserUnsubscribed(subscriber.Login) && !context.CancellationToken.IsCancellationRequested) { await Task.Delay(1000); } if (!context.CancellationToken.IsCancellationRequested) { _grpcObservable.Unregister(subscriber.Login); } }