Exemplo n.º 1
0
        public static void ClassInitialize(TestContext context)
        {
            TestWrapper(async(MixerConnection connection) =>
            {
                ChannelModel channel = await ChannelsServiceUnitTests.GetChannel(connection);

                gameListing = await MixPlayServiceUnitTests.CreateTestGame(connection, channel);

                client = await MixPlayClient.CreateFromChannel(connection, channel, gameListing);

                Assert.IsTrue(await client.Connect());
                Assert.IsTrue(await client.Ready());
            });
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            List <OAuthClientScopeEnum> scopes = new List <OAuthClientScopeEnum>()
            {
                OAuthClientScopeEnum.channel__details__self,
                OAuthClientScopeEnum.channel__update__self,

                OAuthClientScopeEnum.interactive__manage__self,
                OAuthClientScopeEnum.interactive__robot__self,

                OAuthClientScopeEnum.user__details__self,
                OAuthClientScopeEnum.user__log__self,
                OAuthClientScopeEnum.user__notification__self,
                OAuthClientScopeEnum.user__update__self,
            };

            System.Console.WriteLine("Connecting to Mixer...");

            MixerConnection connection = MixerConnection.ConnectViaLocalhostOAuthBrowser(ConfigurationManager.AppSettings["ClientID"], scopes).Result;

            if (connection != null)
            {
                System.Console.WriteLine("Mixer connection successful!");

                UserModel            user    = connection.Users.GetCurrentUser().Result;
                ExpandedChannelModel channel = connection.Channels.GetChannel(user.username).Result;
                System.Console.WriteLine(string.Format("Logged in as: {0}", user.username));

                List <MixPlayGameListingModel> games = new List <MixPlayGameListingModel>(connection.MixPlay.GetOwnedMixPlayGames(channel).Result);
                MixPlayGameListingModel        game  = games.FirstOrDefault();
                if (game != null)
                {
                    System.Console.WriteLine();
                    System.Console.WriteLine(string.Format("Connecting to channel MixPlay using game {0}...", game.name));

                    Program.mixPlayClient = MixPlayClient.CreateFromChannel(connection, channel, game).Result;

                    if (Program.mixPlayClient.Connect().Result&& Program.mixPlayClient.Ready().Result)
                    {
                        MixPlayConnectedSceneGroupCollectionModel scenes = Program.mixPlayClient.GetScenes().Result;
                        if (scenes != null)
                        {
                            Program.scenes.AddRange(scenes.scenes);

                            foreach (MixPlayConnectedSceneModel scene in Program.scenes)
                            {
                                foreach (MixPlayConnectedButtonControlModel button in scene.buttons)
                                {
                                    Program.buttons.Add(button);
                                }

                                foreach (MixPlayConnectedJoystickControlModel joystick in scene.joysticks)
                                {
                                    Program.joysticks.Add(joystick);
                                }

                                foreach (MixPlayConnectedLabelControlModel label in scene.labels)
                                {
                                    Program.labels.Add(label);
                                }

                                foreach (MixPlayConnectedTextBoxControlModel textBox in scene.textBoxes)
                                {
                                    Program.textBoxes.Add(textBox);
                                }

                                foreach (MixPlayControlModel control in scene.allControls)
                                {
                                    control.disabled = false;
                                }

                                Program.mixPlayClient.UpdateControls(scene, scene.allControls).Wait();
                            }

                            Program.mixPlayClient.OnDisconnectOccurred += MixPlayClient_OnDisconnectOccurred;
                            Program.mixPlayClient.OnParticipantJoin    += MixPlayClient_OnParticipantJoin;
                            Program.mixPlayClient.OnParticipantLeave   += MixPlayClient_OnParticipantLeave;
                            Program.mixPlayClient.OnGiveInput          += MixPlayClient_OnGiveInput;

                            while (true)
                            {
                            }
                        }
                    }
                }
            }
        }