/// <summary> /// 双向数据流事件处理 /// </summary> protected async Task StartGrpcStreamAsync() { try { var eventStream = grpcClient.Event(new EventRequest()); while (await eventStream.ResponseStream.MoveNext()) { OnGrpcStreamEvent(eventStream.ResponseStream.Current); } } catch (Exception ex) { StopRequest st = new StopRequest() { }; CallOptions call = new CallOptions() { }; grpcClient.Stop(st, call); var eventResetPayload = new EventResetPayload() { Data = ex.StackTrace }; Emit(eventResetPayload); throw ex; } }
public async Task Handle(StopRequest <ReleaseEnvironmentWidget> request, CancellationToken cancellationToken) { var dialog = new ConfirmationDialog($"Are you sure you want to stop {request.DataContext.Name}?"); if (_dialogService.ShowDialog(dialog) != DialogResult.Yes) { return; } if (request.DataContext.Parent is ReleaseWidget parent) { var api = new AzureDevOpsApi(parent.ConnectionSettings); var response = await api.GetReleasesAsync(parent.Project, parent.DefinitionId, 1, cancellationToken).ConfigureAwait(false); if (response.Count == 0) { throw new Exception("Release not found."); } var release = response.Value.First(); await api.CancelDeploymentAsync(parent.Project, release.Id, request.DataContext.DeploymentId, cancellationToken).ConfigureAwait(false); } }
public async Task IsCoPJourney_IsMapped(StopRequest request) { var mapper = new StopRequestToViewModelMapper(mockCommitmentsApiClient.Object); var result = await mapper.Map(request); Assert.AreEqual(request.IsCoPJourney, result.IsCoPJourney); }
public async Task StartDate_IsMapped(StopRequest request) { var mapper = new StopRequestToViewModelMapper(mockCommitmentsApiClient.Object); var result = await mapper.Map(request); Assert.AreEqual(StartDate, result.StartDate); }
private void PerformStreamingUpdate() { int num; AL.GetSource(this.handle, ALGetSourcei.BuffersProcessed, out num); while (num > 0) { num--; int unqueuedBufferHandle = AL.SourceUnqueueBuffer(this.handle); INativeAudioBuffer unqueuedBuffer = null; for (int i = 0; i < this.strAlBuffers.Length; i++) { NativeAudioBuffer buffer = this.strAlBuffers[i] as NativeAudioBuffer; if (buffer.Handle == unqueuedBufferHandle) { unqueuedBuffer = buffer; break; } } bool eof = !this.streamProvider.ReadStream(unqueuedBuffer); if (!eof) { AL.SourceQueueBuffer(this.handle, unqueuedBufferHandle); } else { this.strStopReq = StopRequest.EndOfStream; } } }
public async Task AccountHashedId_IsMapped(StopRequest request) { var mapper = new StopRequestToViewModelMapper(mockCommitmentsApiClient.Object); var result = await mapper.Map(request); Assert.AreEqual(request.AccountHashedId, result.AccountHashedId); }
private void PerformStreamingBegin() { // Generate streaming buffers this.strAlBuffers = new INativeAudioBuffer[3]; for (int i = 0; i < this.strAlBuffers.Length; ++i) { this.strAlBuffers[i] = DualityApp.AudioBackend.CreateBuffer(); } // Begin streaming this.streamProvider.OpenStream(); // Initially, completely fill all buffers for (int i = 0; i < this.strAlBuffers.Length; ++i) { bool eof = !this.streamProvider.ReadStream(this.strAlBuffers[i]); if (!eof) { AL.SourceQueueBuffer(this.handle, (this.strAlBuffers[i] as NativeAudioBuffer).Handle); } else { this.strStopReq = StopRequest.EndOfStream; break; } } }
public override Task <Response> HandleAsync() { if (request.Handle.IsNullOrWhiteSpace()) { throw new WardenException("Container handle is required."); } else { log.Trace("Destroying container with handle: '{0}'", request.Handle); return(Task.Run <Response>(() => { Container container = GetContainer(); if (container.State != ContainerState.Stopped) { try { var stopRequest = new StopRequest { Handle = request.Handle }; var stopRequestHandler = new StopRequestHandler(containerManager, stopRequest); var stopTask = stopRequestHandler.HandleAsync(); Response stopResponse = stopTask.Result; } catch (Exception ex) { log.WarnException(ex); } } containerManager.DestroyContainer(container); return new DestroyResponse(); })); } }
public StopResponse Execute(StopRequest request) { var game = Games.Get(request.Id); if (game == null || game.Status != GameState.PreDiceRolled) return null; var player = game.Players[game.CurrentPlayer - 1]; foreach (var climber in game.Climbers) { player.Position[climber.Key - 2] = climber.Value; } game.NextPlayer(); game.ResetDice(); game.Climbers.Clear(); Games.Update(game); return new StopResponse { FinalPosition = player.Position, NextPlayer = game.CurrentPlayer }; }
private void ResetLocalState() { strStopReq = StopRequest.Immediately; IsStreamed = false; streamProvider = null; IsStopped = false; }
public void GoUpImpl() { if (TargetFloor == BuildingFactory.NoFloor) { return; } if (!CurrentFloor.Upper.IsNoFloor) { lock (_lock) CurrentFloor = CurrentFloor.Upper; NotifyObservers(); StopRequest stopRequest = StopRequests.Find(sr => sr.FloorNumber == CurrentFloor.FloorNumber); if (stopRequest.UpRequest) { stopRequest.UpRequest = false; Land(); } if (TargetFloor == CurrentFloor) { Land(); return; } Thread.Sleep(100); GoUp(); } }
public async Task API_StopTest() { var widget = new TestWidget(); var handler = new Stop(); var request = StopRequest.Create(widget); await handler.Handle(request, CancellationToken.None); }
public override Task <StopReply> StopRecording(StopRequest request, ServerCallContext context) { _spindelService.StopAsync(); return(Task.FromResult(new StopReply() { Rc = true })); }
public void ThenValidatesAccountHashedId(string accountHashedId, bool expectedValid) { var request = new StopRequest { AccountHashedId = accountHashedId }; AssertValidationResult(x => x.AccountHashedId, request, expectedValid); }
void INativeAudioSource.Stop() { lock (this.strLock) { AL.SourceStop(this.handle); this.strStopReq = StopRequest.Immediately; } }
public void ThenValidatesApprenticeshipHashedId(string apprenticeshipHashedId, bool expectedValid) { var request = new StopRequest { ApprenticeshipHashedId = apprenticeshipHashedId }; AssertValidationResult(x => x.ApprenticeshipHashedId, request, expectedValid); }
// Pauses the process. // Retruns true is successful, false otherwise. public override Task <StopResponse> Stop(StopRequest request, ServerCallContext context) { var sbProcess = GrpcLookupUtils.GetProcess(request.Process, processStore); var result = sbProcess.Stop(); return(Task.FromResult(new StopResponse { Result = result })); }
public IActionResult Stop(StopRequest request) { if (!this.ModelState.IsValid) { return(this.BadRequest()); } return(this.Ok()); }
/// <summary> /// Stops the sound immediately. /// </summary> public void Stop() { if (this.alSource > AlSource_NotAvailable) { AL.SourceStop(this.alSource); } this.strStopReq = StopRequest.Immediately; // The next update will handle everything else }
public override Task <Null> Stop(StopRequest request, ServerCallContext context) { logger.LogWarning($"STOP rpc is called from ServerManager. reason : {request.Reason}"); // TODO: 리소스 정리 life.StopApplication(); return(Task.FromResult(new Null())); }
void IDisposable.Dispose() { if (IsStreamed) { streamProvider.CloseStream(); strStopReq = StopRequest.Immediately; } this.ResetSourceState(); }
private void ResetLocalState() { lock (this.strLock) { this.strStopReq = StopRequest.Immediately; this.isStreamed = false; this.streamProvider = null; this.ReleaseStreamBuffers(); } }
private void OnRequestListenerEvent(JToken obj) { var t = obj?["fname"]?["value"]?.ToString(); if (t == "RequestListener.onStartRequest") { StartRequest?.Invoke(this, obj); } else if (t == "RequestListener.onStopRequest") { StopRequest?.Invoke(this, obj); } }
public async Task Handle(StopRequest <BuildWidget> request, CancellationToken cancellationToken) { var dialog = new ConfirmationDialog($"Are you sure you want to stop {request.DataContext.Name}?"); if (_dialogService.ShowDialog(dialog) != DialogResult.Yes) { return; } var api = new AzureDevOpsApi(request.DataContext.ConnectionSettings); await api.CancelBuildAsync(request.DataContext.Project, request.DataContext.LastBuildId, cancellationToken).ConfigureAwait(false); }
public Task Handle(StopRequest <IISApplicationPool> request, CancellationToken cancellationToken) { using (var iis = ServerManager.OpenRemote(request.DataContext.Host)) { var appPool = iis.ApplicationPools[request.DataContext.ApplicationPoolName]; appPool.Stop(); request.DataContext.State = appPool.State == ObjectState.Started ? State.Ok : State.Failed; return(Task.CompletedTask); } }
public void Stop() { // Arrange var request = new StopRequest(); request.Params.Add(new StopRequestParams { }); // Act var response = _client.Convenience.StopAsync(request).Result; // Assert Assert.AreEqual(Status.Success, response.Result.Status); }
private void PerformStreamingUpdate(AudioData audioDataRes) { int num; AL.GetSource(this.alSource, ALGetSourcei.BuffersProcessed, out num); while (num > 0) { num--; int unqueued; unqueued = AL.SourceUnqueueBuffer(this.alSource); if (OggVorbis.IsStreamValid(this.strOvStr)) { PcmData pcm; bool eof = !OggVorbis.StreamChunk(this.strOvStr, out pcm); if (eof) { OggVorbis.EndStream(ref this.strOvStr); if (this.looped) { OggVorbis.BeginStreamFromMemory(audioDataRes.OggVorbisData, out this.strOvStr); if (pcm.dataLength == 0) { eof = !OggVorbis.StreamChunk(this.strOvStr, out pcm); } else { eof = false; } } } if (pcm.dataLength > 0) { AL.BufferData( unqueued, pcm.channelCount == 1 ? ALFormat.Mono16 : ALFormat.Stereo16, pcm.data, pcm.dataLength * PcmData.SizeOfDataElement, pcm.sampleRate); AL.SourceQueueBuffer(this.alSource, unqueued); } if (pcm.dataLength == 0 || eof) { this.strStopReq = StopRequest.EndOfStream; break; } } } }
public override Task <StopReply> Stop(StopRequest request, ServerCallContext context) { // return base.Stop(request, context); var stopReply = new StopReply() { Status = new MediaContract.Status() { Code = 200, Msg = "Stop Successful!" } }; return(Task.FromResult(stopReply)); }
public async Task Handle(StopRequest <WindowsService> request, CancellationToken cancellationToken) { var dialog = new ConfirmationDialog($"Are you sure you want to stop {request.DataContext.Name}?"); var result = _dialogService.ShowDialog(dialog); if (result != DialogResult.Yes) { return; } _logger.Info($"Stopping {request.DataContext.Name}."); await StopAsync(request.DataContext, cancellationToken).ConfigureAwait(false); }
void INativeAudioSource.Play(IAudioStreamProvider streamingProvider) { lock (this.strLock) { if (!this.isInitial) { throw new InvalidOperationException("Native audio source already in use. To re-use an audio source, reset it first."); } this.isInitial = false; this.isStreamed = true; this.strStopReq = StopRequest.None; this.streamProvider = streamingProvider; AudioBackend.ActiveInstance.EnqueueForStreaming(this); } }
public bool Stop() { var request = new StopRequest { Process = grpcSbProcess }; StopResponse response = null; if (connection.InvokeRpc(() => { response = client.Stop(request); })) { return(response.Result); } return(false); }
void IDisposable.Dispose() { lock (this.strLock) { if (this.isStreamed) { this.streamProvider.CloseStream(); this.strStopReq = StopRequest.Immediately; } this.ResetSourceState(); if (this.handle != 0) { if (AudioBackend.ActiveInstance != null) AudioBackend.ActiveInstance.FreeSourceHandle(this.handle); this.handle = 0; } this.ReleaseStreamBuffers(); } }
void INativeAudioSource.Play(IAudioStreamProvider streamingProvider) { lock (this.strLock) { if (!this.isInitial) throw new InvalidOperationException("Native audio source already in use. To re-use an audio source, reset it first."); this.isInitial = false; this.isStreamed = true; this.strStopReq = StopRequest.None; this.streamProvider = streamingProvider; AudioBackend.ActiveInstance.EnqueueForStreaming(this); } }
private void OnDisposed(bool manually) { if (manually) { if (this.isStreamed) { lock (this.strLock) { OggVorbis.EndStream(ref this.strOvStr); } this.strStopReq = StopRequest.Immediately; } this.attachedTo = null; this.curPriority = -1; lock (this.strLock) { if (this.alSource > AlSource_NotAvailable) { this.CleanupAlSource(); DualityApp.Sound.FreeAlSource(this.alSource); this.alSource = AlSource_NotAvailable; } if (this.strAlBuffers != null) { for (int i = 0; i < this.strAlBuffers.Length; i++) { if (!AL.IsBuffer(this.strAlBuffers[i])) return; AL.DeleteBuffer(this.strAlBuffers[i]); } this.strAlBuffers = null; } this.UnregisterPlaying(); } } }
private void PerformStreamingUpdate(AudioData audioDataRes) { int num; AL.GetSource(this.alSource, ALGetSourcei.BuffersProcessed, out num); while (num > 0) { num--; int unqueued; unqueued = AL.SourceUnqueueBuffer(this.alSource); if (OggVorbis.IsStreamValid(this.strOvStr)) { PcmData pcm; bool eof = !OggVorbis.StreamChunk(this.strOvStr, out pcm); if (eof) { OggVorbis.EndStream(ref this.strOvStr); if (this.looped) { OggVorbis.BeginStreamFromMemory(audioDataRes.OggVorbisData, out this.strOvStr); if (pcm.dataLength == 0) eof = !OggVorbis.StreamChunk(this.strOvStr, out pcm); else eof = false; } } if (pcm.dataLength > 0) { AL.BufferData( unqueued, pcm.channelCount == 1 ? ALFormat.Mono16 : ALFormat.Stereo16, pcm.data, pcm.dataLength * PcmData.SizeOfDataElement, pcm.sampleRate); AL.SourceQueueBuffer(this.alSource, unqueued); } if (pcm.dataLength == 0 || eof) { this.strStopReq = StopRequest.EndOfStream; break; } } } }
/// <summary> /// Stops the sound immediately. /// </summary> public void Stop() { if (this.alSource > AlSource_NotAvailable) AL.SourceStop(this.alSource); this.strStopReq = StopRequest.Immediately; // The next update will handle everything else }