/// <summary>
        /// Connects to the OBS WebSocket server
        /// </summary>
        /// <returns></returns>
        public void Connect(ObsWebSocketClientSettings settings)
        {
            if (obsWebSocket.IsConnected)
            {
                obsWebSocket.Disconnect();
            }

            obsWebSocket.Connect($"ws://{settings.IpAddress}:{settings.Port}", settings.Password ?? "");
        }
Ejemplo n.º 2
0
        private void ConnectOrDisconnect(object sender, EventArgs e)
        {

            BeginInvoke((MethodInvoker)(() => {
                try {
                    StatusPanel.Visible = true;

                    if (_obs.IsConnected) {
                        StatusPanel.BackColor = Color.Green;
                        StatusLabel.Text = "接続中";

                    }
                    else {
                        StatusPanel.BackColor = Color.Red;
                        StatusLabel.Text = "切断";
                        streamingStatus.Text = "";
                        RecordingStatus.Text = "";
                    }

                    StatusPanel.Refresh();

                    connectbtn.Text = _obs.IsConnected ? "切断" : "接続";
                    RefreshControlsStatus();

                    Thread.Sleep(2000);
                    StatusPanel.Visible = false;

                    if (!_obs.IsConnected) return;
                    var streamStatus = _obs.Api.GetStreamingStatus();
                    if (streamStatus.IsStreaming)
                        onStreamingStateChange(_obs, OutputState.Started);
                    else
                        onStreamingStateChange(_obs, OutputState.Stopped);

                    if (streamStatus.IsRecording)
                        onRecordingStateChange(_obs, OutputState.Started);
                    else
                        onRecordingStateChange(_obs, OutputState.Stopped);
                }
                catch (ErrorResponseException) {
                    MessageBox.Show("エラーが発生しました。Tailobsを再起動させてください。", "OBSの接続に失敗しました");
                    _obs.Disconnect();
                    ConnectOrDisconnect(null, null);
                    return;
                }
            }));

        }
Ejemplo n.º 3
0
 public override void Disable()
 {
     if (_obs != null)
     {
         _obs.Heartbeat -= UpdateHeartbeat;
         _obs.Disconnect();
     }
 }
Ejemplo n.º 4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (_obs.IsConnected && Properties.Settings.Default.WebsocketHost != txtWebsocketHost.Text)
     {
         _obs.Disconnect();
     }
     Properties.Settings.Default.WebsocketHost     = txtWebsocketHost.Text;
     Properties.Settings.Default.WebsocketPassword = txtWebsocketPassword.Text;
     Properties.Settings.Default.MicroflexHost     = txtMicroflexHost.Text;
     Properties.Settings.Default.SceneMapping      = JsonConvert.SerializeObject(mappings);
     Properties.Settings.Default.Save();
 }
Ejemplo n.º 5
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_DisposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects)
                }

                _OBS.Disconnect();
                _OBS           = null;
                _DisposedValue = true;
            }
        }
Ejemplo n.º 6
0
        private static async Task Main(string[] args)
        {
            Settings = SettingLoader.Load();

            SetTimer();

            ObsWebSocket.Connected    += ObsWebSocket_Connected;
            ObsWebSocket.Disconnected += ObsWebSocket_Disconnected;

            ObsWebSocket.Connect(Settings.Url, Settings.Password);

            await ConsoleHost.WaitAsync();

            ObsWebSocket.Disconnect();
Ejemplo n.º 7
0
        public static void Close()
        {
            if (_obs == null || !_running)
            {
                return;
            }

            try
            {
                _thread?.Abort();
            }
            catch
            { }
            _thread = null;
            try
            {
                _obs?.Disconnect();
            }
            catch
            { }
            _obs     = null;
            _running = false;
        }
Ejemplo n.º 8
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     if (!_obs.IsConnected)
     {
         try
         {
             _obs.Connect(txtServerIP.Text, txtServerPassword.Text);
         }
         catch (AuthFailureException)
         {
             MessageBox.Show("Authentication failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return;
         }
         catch (ErrorResponseException ex)
         {
             MessageBox.Show("Connect failed : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return;
         }
     }
     else
     {
         _obs.Disconnect();
     }
 }