コード例 #1
0
ファイル: GrpcPuppet.cs プロジェクト: wechaty/dotnet-wechaty
        /// <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;
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public async Task StartDate_IsMapped(StopRequest request)
        {
            var mapper = new StopRequestToViewModelMapper(mockCommitmentsApiClient.Object);
            var result = await mapper.Map(request);

            Assert.AreEqual(StartDate, result.StartDate);
        }
コード例 #5
0
ファイル: NativeAudioSource.cs プロジェクト: rolane/duality
        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;
                }
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
ファイル: NativeAudioSource.cs プロジェクト: pyneer/case
        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;
                }
            }
        }
コード例 #8
0
        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();
                }));
            }
        }
コード例 #9
0
ファイル: Stop.cs プロジェクト: jamesfoster/CantStop
		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
				};
		}
コード例 #10
0
ファイル: NativeAudioSource.cs プロジェクト: razluta/jazz2
 private void ResetLocalState()
 {
     strStopReq     = StopRequest.Immediately;
     IsStreamed     = false;
     streamProvider = null;
     IsStopped      = false;
 }
コード例 #11
0
        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();
            }
        }
コード例 #12
0
        public async Task API_StopTest()
        {
            var widget  = new TestWidget();
            var handler = new Stop();
            var request = StopRequest.Create(widget);

            await handler.Handle(request, CancellationToken.None);
        }
コード例 #13
0
ファイル: RecordingService.cs プロジェクト: iSpindel/iSpindel
 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);
        }
コード例 #15
0
ファイル: NativeAudioSource.cs プロジェクト: rolane/duality
 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);
        }
コード例 #17
0
        // 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
            }));
        }
コード例 #18
0
        public IActionResult Stop(StopRequest request)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest());
            }

            return(this.Ok());
        }
コード例 #19
0
 /// <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
 }
コード例 #20
0
        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()));
        }
コード例 #21
0
ファイル: NativeAudioSource.cs プロジェクト: razluta/jazz2
        void IDisposable.Dispose()
        {
            if (IsStreamed)
            {
                streamProvider.CloseStream();
                strStopReq = StopRequest.Immediately;
            }

            this.ResetSourceState();
        }
コード例 #22
0
ファイル: NativeAudioSource.cs プロジェクト: rolane/duality
        private void ResetLocalState()
        {
            lock (this.strLock)
            {
                this.strStopReq     = StopRequest.Immediately;
                this.isStreamed     = false;
                this.streamProvider = null;

                this.ReleaseStreamBuffers();
            }
        }
コード例 #23
0
        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);
            }
        }
コード例 #24
0
        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);
        }
コード例 #25
0
        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);
            }
        }
コード例 #26
0
        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);
        }
コード例 #27
0
        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;
                    }
                }
            }
        }
コード例 #28
0
        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));
        }
コード例 #29
0
        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);
        }
コード例 #30
0
ファイル: NativeAudioSource.cs プロジェクト: rolane/duality
        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);
            }
        }
コード例 #31
0
        public bool Stop()
        {
            var request = new StopRequest
            {
                Process = grpcSbProcess
            };
            StopResponse response = null;

            if (connection.InvokeRpc(() =>
            {
                response = client.Stop(request);
            }))
            {
                return(response.Result);
            }
            return(false);
        }
コード例 #32
0
		private void ResetLocalState()
		{
			lock (this.strLock)
			{
				this.strStopReq = StopRequest.Immediately;
				this.isStreamed = false;
				this.streamProvider = null;

				this.ReleaseStreamBuffers();
			}
		}
コード例 #33
0
		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();
			}
		}
コード例 #34
0
		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;
				}
			}
		}
コード例 #35
0
		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);
			}
		}
コード例 #36
0
		void INativeAudioSource.Stop()
		{
			lock (this.strLock)
			{
				AL.SourceStop(this.handle);
				this.strStopReq = StopRequest.Immediately;
			}
		}
コード例 #37
0
ファイル: SoundInstance.cs プロジェクト: KSLcom/duality
		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();
				}
			}
		}
コード例 #38
0
ファイル: SoundInstance.cs プロジェクト: KSLcom/duality
		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;
					}
				}
			}
		}
コード例 #39
0
ファイル: SoundInstance.cs プロジェクト: KETMGaming/duality
		/// <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
		}