Example #1
0
        private void Obsmidi_StatusChanged(COBSMidiRemote sender, EOBSCStatus type)
        {
            if (InvokeRequired)
            {
                var d = new Obsmidi_StatusChangedInvoked(Obsmidi_StatusChanged);
                Invoke(d, new object[] { sender, type });
                return;
            }

            ws_info.Visible = false;
            if (type == EOBSCStatus.Connected || type == EOBSCStatus.Connecting || type == EOBSCStatus.DeviceReady)
            {
                ws_info.Visible = true;
                LockFormElements();
                Program.ChangeTrayIcon(true);

                if (type == EOBSCStatus.Connecting || type == EOBSCStatus.DeviceReady)
                {
                    btn_start.Text  = "...";
                    ws_info.Visible = true;
                    ws_info.Text    = type == EOBSCStatus.DeviceReady ? "HW Ready ..." : Program.res.GetString("connecting");
                }
                else if (type == EOBSCStatus.Connected)
                {
                    ws_info.Text   = obsmidi.GetVersionInfo();
                    btn_start.Text = Program.res.GetString("disconnect");
                }
            }
            else
            {
                if (type == EOBSCStatus.WrongAuth)
                {
                    MessageBox.Show(
                        Program.res.GetString("error_password"),
                        Program.res.GetString("error"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else if (type == EOBSCStatus.Error || type == EOBSCStatus.Unknown)
                {
                    MessageBox.Show(
                        Program.res.GetString("error_connect"),
                        Program.res.GetString("error"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else if (type == EOBSCStatus.DeviceError)
                {
                    MessageBox.Show(
                        Program.res.GetString("error_wrongdevice"),
                        Program.res.GetString("error"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                btn_start.Text = Program.res.GetString("connect");
                UnlockFormElements();
                Program.ChangeTrayIcon(false);
            }
        }
Example #2
0
        private async void Obs_ConnectionStatus(IOBSConnector sender, EOBSCStatus eventdata)
        {
            if (eventdata == EOBSCStatus.Connected)
            {
                Connected  = true;
                Connecting = false;
                Midi.Display(EMidiOBSItemType.ReloadObsData, EMidiOBSOutputType.Off, -1, -1, true);

                //await Obs.Reload();

                Midi.Display(EMidiOBSItemType.ReloadObsData, EMidiOBSOutputType.On, -1, -1, true);
                Midi.RenderSurface();
            }
            else if (eventdata == EOBSCStatus.Disconnected)
            {
                Midi.ResetSurface();
            }

            if (StatusChanged != null)
            {
                StatusChanged(this, eventdata);
            }
        }
Example #3
0
        private async void Ws_ConnectionStatus(SLOBSWebsocket sender, SSLOBSConnectionEvent eventdata)
        {
            if (ConnectionStatus != null)
            {
                EOBSCStatus translatedEventType = EOBSCStatus.Unknown;
                if (eventdata.state == ESLOBSConnectionState.Connected)
                {
                    if (_auth != null)
                    {
                        var auth = await ws.Auth(_auth);

                        if (auth)
                        {
                            translatedEventType = EOBSCStatus.Connected;
                            Connected           = true;
                            statusTimer.Enabled = true;
                        }
                        else
                        {
                            translatedEventType = EOBSCStatus.WrongAuth;
                            Connected           = false;
                            statusTimer.Enabled = false;
                        }
                    }
                    else
                    {
                        translatedEventType = EOBSCStatus.Connected;
                        Connected           = true;
                        statusTimer.Enabled = true;
                    }
                }
                else if (eventdata.state == ESLOBSConnectionState.Connecting)
                {
                    translatedEventType = EOBSCStatus.Connecting;
                    Connected           = false;
                    statusTimer.Enabled = false;
                }
                else if (eventdata.state == ESLOBSConnectionState.Error)
                {
                    translatedEventType = EOBSCStatus.Error;
                    Connected           = false;
                    statusTimer.Enabled = false;
                }
                else if (eventdata.state == ESLOBSConnectionState.Disconnected)
                {
                    translatedEventType = EOBSCStatus.Disconnected;
                    Connected           = false;
                    statusTimer.Enabled = false;
                }

                if (Connected)
                {
                    //subscribing all of possible events
                    await ws.SubscribeToEvent("sceneSwitched", "ScenesService");

                    await ws.SubscribeToEvent("sceneAdded", "ScenesService");

                    await ws.SubscribeToEvent("sceneRemoved", "ScenesService");

                    await ws.SubscribeToEvent("itemAdded", "ScenesService");

                    await ws.SubscribeToEvent("itemRemoved", "ScenesService");

                    await ws.SubscribeToEvent("itemUpdated", "ScenesService");

                    await ws.SubscribeToEvent("streamingStatusChange", "StreamingService");

                    await ws.SubscribeToEvent("sourceAdded", "SourcesService");

                    await ws.SubscribeToEvent("sourceRemoved", "SourcesService");

                    await ws.SubscribeToEvent("sourceUpdated", "SourcesService");
                }

                ConnectionStatus(this, translatedEventType);
            }
        }