/// <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 ?? "");
        }
Beispiel #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;
                }
            }));

        }
Beispiel #3
0
 public override void Disable()
 {
     if (_obs != null)
     {
         _obs.Heartbeat -= UpdateHeartbeat;
         _obs.Disconnect();
     }
 }
Beispiel #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();
 }
Beispiel #5
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_DisposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects)
                }

                _OBS.Disconnect();
                _OBS           = null;
                _DisposedValue = true;
            }
        }
Beispiel #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();
        public static void Close()
        {
            if (_obs == null || !_running)
            {
                return;
            }

            try
            {
                _thread?.Abort();
            }
            catch
            { }
            _thread = null;
            try
            {
                _obs?.Disconnect();
            }
            catch
            { }
            _obs     = null;
            _running = false;
        }
Beispiel #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();
     }
 }