예제 #1
0
        private async void buttonStart_Click(object sender, EventArgs e)
        {
            // TODO: Handle the parse better when bindingsource support come.
            settings.IpAddress = tbIpAddress.Text;
            settings.Port      = int.Parse(tbPort.Text);
            settings.Password  = tbPassword.Text;

            await client.ConnectAsync(settings);
        }
예제 #2
0
        public async Task OnExecuteAsync()
        {
            ObsWebSocketClientSettings settings = await ReadSettings().ConfigureAwait(false);

            logger.LogInformation("Try to connect using Address: {IpAddress}:{Port}", settings.IpAddress, settings.Port);

            try
            {
                await client.ConnectAsync(settings).ConfigureAwait(false);

                logger.LogInformation("Connected");
            }
            catch (Exception ex)
            {
                logger.LogError("Cannot connect: {Message}", ex.Message);
            }

            /* Suscribe the client. */
            subscriber.Subscribe("OBS", async command =>
            {
                logger.LogTrace("Received command: {Command}", command);

                if (command == "**START")
                {
                    await client.StartRecordingAsync();
                }
                else if (command == "**STOP")
                {
                    await client.StopRecordingAsync();
                }
                else if (string.IsNullOrEmpty(command))
                {
                    await client.ChangeSceneAsync(command);
                }
            });


            if (!NoGui)
            {
                logger.LogInformation("Runnig with GUI");
                ConsoleWindowController.Hide();
                RunGui(settings);

                /* Save if running GUI. */
                await settingsRepository.SaveAsync(settings);
            }
            else
            {
                logger.LogInformation("Runnig without GUI");
                Console.ReadKey();
            }
        }