コード例 #1
0
        private static void MixPlayClient_OnGiveInput(object sender, MixPlayGiveInputModel e)
        {
            System.Console.WriteLine("Input Received: " + e.participantID + " - " + e.input.eventType + " - " + e.input.controlID);

            if (e.input.eventType.Equals("mousedown") && e.transactionID != null)
            {
                MixPlayConnectedButtonControlModel button = Program.buttons.FirstOrDefault(b => b.controlID.Equals(e.input.controlID));
                if (button != null)
                {
                    MixPlayConnectedSceneModel scene = Program.scenes.FirstOrDefault(s => s.buttons.Contains(button));
                    if (scene != null)
                    {
                        button.cooldown = DateTimeOffset.Now.AddSeconds(10).ToUnixTimeMilliseconds();

                        Program.mixPlayClient.UpdateControls(scene, new List <MixPlayConnectedButtonControlModel>()
                        {
                            button
                        }).Wait();
                        System.Console.WriteLine("Sent 10 second cooldown to button: " + e.input.controlID);
                    }
                }

                Program.mixPlayClient.CaptureSparkTransaction(e.transactionID).Wait();
                System.Console.WriteLine("Spark Transaction Captured: " + e.participantID + " - " + e.input.eventType + " - " + e.input.controlID);
            }
        }
コード例 #2
0
        private MethodPacket BuildDeleteControlsPacket(MixPlayConnectedSceneModel scene, IEnumerable <MixPlayControlModel> controls)
        {
            Validator.ValidateVariable(scene, "scene");
            Validator.ValidateList(controls, "controls");
            JObject parameters = new JObject();

            parameters.Add("sceneID", scene.sceneID);
            parameters.Add("controlIDs", JArray.FromObject(controls.Select(c => c.controlID)));
            return(new MethodParamsPacket("deleteControls", parameters));
        }
コード例 #3
0
        private MethodPacket BuildDeleteScenePacket(MixPlayConnectedSceneModel sceneToDelete, MixPlayConnectedSceneModel sceneToReplace)
        {
            Validator.ValidateVariable(sceneToDelete, "sceneToDelete");
            Validator.ValidateVariable(sceneToReplace, "sceneToReplace");
            JObject parameters = new JObject();

            parameters.Add("sceneID", sceneToDelete.sceneID);
            parameters.Add("reassignSceneID", sceneToReplace.sceneID);
            return(new MethodParamsPacket("deleteScene", parameters));
        }
コード例 #4
0
        public void CreateGetUpdateDeleteGroup()
        {
            this.MixPlayWrapper(async(MixerConnection connection, MixPlayClient client) =>
            {
                MixPlayConnectedSceneModel testScene = await this.CreateScene(client);

                this.ClearPackets();

                MixPlayGroupModel testGroup = new MixPlayGroupModel()
                {
                    groupID = GroupID,
                    sceneID = testScene.sceneID
                };

                bool result = await client.CreateGroupsWithResponse(new List <MixPlayGroupModel>()
                {
                    testGroup
                });

                Assert.IsTrue(result);

                this.ClearPackets();

                MixPlayGroupCollectionModel groups = await client.GetGroups();

                Assert.IsNotNull(groups);
                Assert.IsNotNull(groups.groups);
                Assert.IsTrue(groups.groups.Count > 0);

                testGroup = groups.groups.FirstOrDefault(g => g.groupID.Equals(GroupID));
                MixPlayGroupModel defaultGroup = groups.groups.FirstOrDefault(g => g.groupID.Equals("default"));

                this.ClearPackets();

                groups = await client.UpdateGroupsWithResponse(new List <MixPlayGroupModel>()
                {
                    testGroup
                });

                Assert.IsNotNull(groups);
                Assert.IsNotNull(groups.groups);
                Assert.IsTrue(groups.groups.Count > 0);

                testGroup = groups.groups.FirstOrDefault(g => g.groupID.Equals(GroupID));

                this.ClearPackets();

                result = await client.DeleteGroupWithResponse(testGroup, defaultGroup);

                Assert.IsTrue(result);

                await this.DeleteScene(client, testScene);
            });
        }
コード例 #5
0
        private MethodPacket BuildUpdateControlsPacket(MixPlayConnectedSceneModel scene, IEnumerable <MixPlayControlModel> controls)
        {
            Validator.ValidateVariable(scene, "scene");
            Validator.ValidateList(controls, "controls");
            JObject parameters = new JObject();

            parameters.Add("sceneID", scene.sceneID);
            parameters.Add("controls", JArray.FromObject(controls, new JsonSerializer {
                NullValueHandling = NullValueHandling.Ignore
            }));
            return(new MethodParamsPacket("updateControls", parameters));
        }
コード例 #6
0
        private async Task DeleteScene(MixPlayClient client, MixPlayConnectedSceneModel scene)
        {
            this.ClearPackets();

            MixPlayConnectedSceneGroupCollectionModel scenes = await client.GetScenes();

            Assert.IsNotNull(scenes);
            Assert.IsNotNull(scenes.scenes);
            Assert.IsTrue(scenes.scenes.Count >= 2);

            MixPlayConnectedSceneModel backupScene = scenes.scenes.FirstOrDefault(s => s.sceneID.Equals("default"));

            bool result = await client.DeleteSceneWithResponse(scene, backupScene);

            Assert.IsTrue(result);
        }
コード例 #7
0
        private async Task <MixPlayConnectedSceneModel> GetScene(MixPlayClient client)
        {
            this.ClearPackets();

            MixPlayConnectedSceneGroupCollectionModel scenes = await client.GetScenes();

            Assert.IsNotNull(scenes);
            Assert.IsNotNull(scenes.scenes);
            Assert.IsTrue(scenes.scenes.Count >= 2);

            MixPlayConnectedSceneModel testScene = scenes.scenes.FirstOrDefault(s => s.sceneID.Equals(SceneID));

            Assert.IsNotNull(testScene);

            return(testScene);
        }
コード例 #8
0
        private async Task <MixPlayConnectedSceneModel> CreateScene(MixPlayClient client)
        {
            this.ClearPackets();

            MixPlayConnectedSceneCollectionModel scenes = await client.CreateScenesWithResponse(new List <MixPlayConnectedSceneModel>() { new MixPlayConnectedSceneModel()
                                                                                                                                          {
                                                                                                                                              sceneID = SceneID
                                                                                                                                          } });

            Assert.IsNotNull(scenes);
            Assert.IsNotNull(scenes.scenes);
            Assert.IsTrue(scenes.scenes.Count >= 1);

            MixPlayConnectedSceneModel testScene = scenes.scenes.FirstOrDefault(s => s.sceneID.Equals(SceneID));

            Assert.IsNotNull(testScene);

            return(await this.GetScene(client));
        }
コード例 #9
0
        public void CreateUpdateDeleteControl()
        {
            this.MixPlayWrapper(async(MixerConnection connection, MixPlayClient client) =>
            {
                MixPlayConnectedSceneModel testScene = await this.CreateScene(client);

                this.ClearPackets();

                MixPlayControlModel testControl = MixPlayClientUnitTests.CreateTestButton();

                List <MixPlayControlModel> controls = new List <MixPlayControlModel>()
                {
                    testControl, MixPlayClientUnitTests.CreateTestJoystick()
                };
                bool result = await client.CreateControlsWithResponse(testScene, controls);

                Assert.IsTrue(result);

                testScene   = await this.GetScene(client);
                testControl = testScene.buttons.FirstOrDefault(c => c.controlID.Equals(ButtonControlID));
                Assert.IsNotNull(testControl);

                controls = new List <MixPlayControlModel>()
                {
                    testControl
                };
                MixPlayConnectedControlCollectionModel controlCollection = await client.UpdateControlsWithResponse(testScene, controls);

                Assert.IsNotNull(controlCollection);
                Assert.IsNotNull(controlCollection.buttons);

                testScene   = await this.GetScene(client);
                testControl = testScene.buttons.FirstOrDefault(c => c.controlID.Equals(ButtonControlID));
                Assert.IsNotNull(testControl);

                result = await client.DeleteControlsWithResponse(testScene, controls);

                Assert.IsTrue(result);

                await this.DeleteScene(client, testScene);
            });
        }
コード例 #10
0
        public void CreateGetUpdateDeleteScene()
        {
            this.MixPlayWrapper(async(MixerConnection connection, MixPlayClient client) =>
            {
                MixPlayConnectedSceneModel testScene = await this.CreateScene(client);

                this.ClearPackets();

                MixPlayConnectedSceneCollectionModel scenes = await client.UpdateScenesWithResponse(new List <MixPlayConnectedSceneModel>()
                {
                    testScene
                });

                Assert.IsNotNull(scenes);
                Assert.IsNotNull(scenes.scenes);
                Assert.IsTrue(scenes.scenes.Count >= 1);

                testScene = scenes.scenes.FirstOrDefault(s => s.sceneID.Equals(SceneID));

                await this.DeleteScene(client, testScene);
            });
        }
コード例 #11
0
 /// <summary>
 /// Deletes the specified controls from the specified scene.
 /// </summary>
 /// <param name="scene">The scene to delete controls from</param>
 /// <param name="controls">The controls to delete</param>
 /// <returns>Whether the operation succeeded</returns>
 public async Task <bool> DeleteControlsWithResponse(MixPlayConnectedSceneModel scene, IEnumerable <MixPlayControlModel> controls)
 {
     return(this.VerifyNoErrors(await this.SendAndListen(this.BuildDeleteControlsPacket(scene, controls))));
 }
コード例 #12
0
 /// <summary>
 /// Deletes the specified controls from the specified scene.
 /// </summary>
 /// <param name="scene">The scene to delete controls from</param>
 /// <param name="controls">The controls to delete</param>
 /// <returns>The task object representing the asynchronous operation</returns>
 public async Task DeleteControls(MixPlayConnectedSceneModel scene, IEnumerable <MixPlayControlModel> controls)
 {
     await this.Send(this.BuildDeleteControlsPacket(scene, controls));
 }
コード例 #13
0
 /// <summary>
 /// Updates the specified controls for the specified scene.
 /// </summary>
 /// <param name="scene">The scene to update controls for</param>
 /// <param name="controls">The controls to update</param>
 /// <returns>The updated controls</returns>
 public async Task <MixPlayConnectedControlCollectionModel> UpdateControlsWithResponse(MixPlayConnectedSceneModel scene, IEnumerable <MixPlayControlModel> controls)
 {
     return(await this.SendAndListen <MixPlayConnectedControlCollectionModel>(this.BuildUpdateControlsPacket(scene, controls)));
 }
コード例 #14
0
 /// <summary>
 /// Deletes and replaced the specified scene.
 /// </summary>
 /// <param name="sceneToDelete">The scene to delete</param>
 /// <param name="sceneToReplace">The scene to replace with</param>
 /// <returns>Whether the operation succeeded</returns>
 public async Task <bool> DeleteSceneWithResponse(MixPlayConnectedSceneModel sceneToDelete, MixPlayConnectedSceneModel sceneToReplace)
 {
     return(this.VerifyNoErrors(await this.SendAndListen(this.BuildDeleteScenePacket(sceneToDelete, sceneToReplace))));
 }
コード例 #15
0
 /// <summary>
 /// Deletes and replaced the specified scene.
 /// </summary>
 /// <param name="sceneToDelete">The scene to delete</param>
 /// <param name="sceneToReplace">The scene to replace with</param>
 /// <returns>The task object representing the asynchronous operation</returns>
 public async Task DeleteScene(MixPlayConnectedSceneModel sceneToDelete, MixPlayConnectedSceneModel sceneToReplace)
 {
     await this.Send(this.BuildDeleteScenePacket(sceneToDelete, sceneToReplace));
 }