Example #1
0
        private void Ws_StreamingStatusChanged(SLOBSWebsocket sender, ESLOBSStreamingState state)
        {
            SLOBSStreamingState input = new SLOBSStreamingState();

            input.StreamingStatus = state;
            var output = _translateStreamingStatus(input);

            output.Record = _state.Record;
            output.Replay = _state.Replay;

            if (StreamingStatusChanged != null)
            {
                StreamingStatusChanged(this, output);
            }
        }
        private void ProcessEvent(JObject body)
        {
            if (body["result"] == null)
            {
                return;
            }
            if (body["result"]["_type"] == null || (string)body["result"]["_type"] != "EVENT")
            {
                return;
            }
            if (body["result"]["resourceId"] == null)
            {
                return;
            }
            switch ((string)body["result"]["resourceId"])
            {
            case "ScenesService.sceneSwitched":
                if (SceneChanged != null)
                {
                    SceneChanged(this, new SLOBSSceneEvent {
                        Type = ESLOBSEventType.SceneSwitched, ResourceId = (string)body["result"]["resourceId"], Scene = new SLOBSScene((JObject)body["result"]["data"])
                    });
                }
                break;

            case "ScenesService.sceneAdded":
                if (SceneChanged != null)
                {
                    SceneChanged(this, new SLOBSSceneEvent {
                        Type = ESLOBSEventType.SceneAdded, ResourceId = (string)body["result"]["resourceId"], Scene = new SLOBSScene((JObject)body["result"]["data"])
                    });
                }
                break;

            case "ScenesService.sceneRemoved":
                if (SceneChanged != null)
                {
                    SceneChanged(this, new SLOBSSceneEvent {
                        Type = ESLOBSEventType.SceneRemoved, ResourceId = (string)body["result"]["resourceId"], Scene = new SLOBSScene((JObject)body["result"]["data"])
                    });
                }
                break;

            case "ScenesService.itemAdded":
                if (SceneItemChanged != null)
                {
                    SceneItemChanged(this, new SLOBSSceneItemEvent {
                        Type = ESLOBSEventType.SceneItemAdded, ResourceId = (string)body["result"]["resourceId"], SceneItem = new SLOBSSceneItem((JObject)body["result"]["data"])
                    });
                }
                break;

            case "ScenesService.itemRemoved":
                if (SceneItemChanged != null)
                {
                    SceneItemChanged(this, new SLOBSSceneItemEvent {
                        Type = ESLOBSEventType.SceneItemRemoved, ResourceId = (string)body["result"]["resourceId"], SceneItem = new SLOBSSceneItem((JObject)body["result"]["data"])
                    });
                }
                break;

            case "ScenesService.itemUpdated":
                if (SceneItemChanged != null)
                {
                    SceneItemChanged(this, new SLOBSSceneItemEvent {
                        Type = ESLOBSEventType.SceneItemUpdated, ResourceId = (string)body["result"]["resourceId"], SceneItem = new SLOBSSceneItem((JObject)body["result"]["data"])
                    });
                }
                break;

            case "StreamingService.streamingStatusChange":
                if (StreamingStatusChanged != null)
                {
                    var str  = (string)body["result"]["data"];
                    var estr = str.ToUpper().Substring(0, 1) + str.ToLower().Substring(1);
                    try
                    {
                        ESLOBSStreamingState state = (ESLOBSStreamingState)Enum.Parse(typeof(ESLOBSStreamingState), estr);
                        StreamingStatusChanged(this, state);
                    }catch (Exception e)
                    {}
                }
                break;

            case "SourcesService.sourceAdded":
                if (SourceChanged != null)
                {
                    SourceChanged(this, new SLOBSSourceEvent {
                        Type = ESLOBSEventType.SourceAdded, ResourceId = (string)body["result"]["resourceId"], Source = new SLOBSSource((JObject)body["result"]["data"])
                    });
                }
                break;

            case "SourcesService.sourceRemoved":
                if (SourceChanged != null)
                {
                    SourceChanged(this, new SLOBSSourceEvent {
                        Type = ESLOBSEventType.SourceRemoved, ResourceId = (string)body["result"]["resourceId"], Source = new SLOBSSource((JObject)body["result"]["data"])
                    });
                }
                break;

            case "SourcesService.sourceUpdated":
                if (SourceChanged != null)
                {
                    SourceChanged(this, new SLOBSSourceEvent {
                        Type = ESLOBSEventType.SourceUpdated, ResourceId = (string)body["result"]["resourceId"], Source = new SLOBSSource((JObject)body["result"]["data"])
                    });
                }
                break;
            }
        }