Exemplo n.º 1
0
        private void OnExecute()
        {
            var display = DisplayIdentifier.Parse(Environment.GetEnvironmentVariable("DISPLAY"));

            // Ctrl + C が押されたときの動作を設定しておく
            var w   = new ManualResetEvent(false);
            var cts = new CancellationTokenSource();

            cts.Token.Register(() =>
            {
                Log.WriteMessage("Terminating");
                w.Set();
            });
            Console.CancelKeyPress += (_, e) =>
            {
                e.Cancel = true;
                cts.Cancel();
            };

            GrpcEnvironment.SetLogger(new ConsoleLogger());

            // サーバー開始
            // 0.0.0.0 を指定: https://github.com/grpc/grpc/issues/10570
            using (var wagahighOperator = LocalWagahighOperator.StartProcessAsync(this.Directory ?? "", display).Result)
                using (var server = new GrpcToaServer("0.0.0.0", this.Port, wagahighOperator))
                {
                    server.Start();
                    Log.WriteMessage("Listening " + this.Port);
                    w.WaitOne();
                }
        }
Exemplo n.º 2
0
        private async Task <WagahighOperator> CreateWagahighOperatorAsync()
        {
            if (this.ToaHost != null)
            {
                this.Logger.Info($"Toa サーバー {this.ToaHost}:{this.ToaPort} に接続します。");
                var remoteOperator = new GrpcRemoteWagahighOperator(this.ToaHost, this.ToaPort);
                await remoteOperator.ConnectAsync().ConfigureAwait(false);

                return(remoteOperator);
            }
            else
            {
                this.Logger.Info("ワガママハイスペックを起動します。");
                var display = DisplayIdentifier.Parse(Environment.GetEnvironmentVariable("DISPLAY"));
                return(await LocalWagahighOperator.StartProcessAsync(this.Directory ?? "", display).ConfigureAwait(false));
            }
        }