public async Task Should_Support_Progress_From_Sever_To_Client() { var(client, server) = await Initialize(ConfigureClient, ConfigureServer); var data = new List <ProgressEvent>(); client.ProgressManager.Progress.Take(1).Switch().Subscribe(x => data.Add(x)); using var workDoneObserver = server.ProgressManager.Create( new ProgressStartEvent { Cancellable = true, Message = "Begin", Percentage = 0, Title = "Work is pending" }, onComplete: () => new ProgressEndEvent { Message = "End" } ); workDoneObserver.OnNext( new ProgressUpdateEvent { Percentage = 10, Message = "Report 1" } ); workDoneObserver.OnNext( new ProgressUpdateEvent { Percentage = 20, Message = "Report 2" } ); workDoneObserver.OnNext( new ProgressUpdateEvent { Percentage = 30, Message = "Report 3" } ); workDoneObserver.OnNext( new ProgressUpdateEvent { Percentage = 40, Message = "Report 4" } ); workDoneObserver.OnCompleted(); await data.DelayUntilCount(6, CancellationToken); var results = data.Select( z => z switch { ProgressStartEvent begin => begin.Message, ProgressUpdateEvent begin => begin.Message, ProgressEndEvent begin => begin.Message, _ => throw new NotSupportedException() }
Task <Unit> IRequestHandler <ProgressUpdateEvent, Unit> .Handle(ProgressUpdateEvent request, CancellationToken cancellationToken) { if (_activeObservables.TryGetValue(request.ProgressId, out var observable)) { observable.OnNext(request); } // TODO: Add log message for unhandled? return(Unit.Task); }
public override void EvaluatePlayerPosition(Vector3 p_position) { if (CalculateProgress(p_position - OFFSET_VECTOR) >= 1f) { if (ProgressUpdateEvent != null) { ProgressUpdateEvent.Invoke(1f); } } }
private void Update() { if (!_shouldSendProgress) { return; } if (ProgressUpdateEvent != null) { ProgressUpdateEvent.Invoke(CalculateProgress()); } }
public void OnNext(ProgressUpdateEvent value) { if (_disposable.IsDisposed) { return; } if (EqualityComparer <ProgressToken> .Default.Equals(value.ProgressId, default)) { value.ProgressId = ProgressId; } _router.SendNotification(value); }
public void OnNext(ProgressUpdateEvent value) { if (_disposable.IsDisposed) { return; } // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (value.ProgressId is null) { value = value with { ProgressId = ProgressId }; } _router.SendNotification(value); }
private static void UpdateProgress(string message) { ProgressUpdateEvent?.Invoke(message); }