コード例 #1
0
        private MethodPacket BuildUpdateGroupsPacket(IEnumerable <InteractiveGroupModel> groups)
        {
            Validator.ValidateList(groups, "groups");
            InteractiveGroupCollectionModel collection = new InteractiveGroupCollectionModel()
            {
                groups = groups.ToList()
            };

            return(new MethodParamsPacket("updateGroups", JObject.FromObject(collection)));
        }
コード例 #2
0
 private void InteractiveClient_OnGroupUpdate(object sender, InteractiveGroupCollectionModel e)
 {
     if (e.groups != null)
     {
         foreach (InteractiveGroupModel group in e.groups)
         {
             this.InteractiveDataTextBlock.Text += "Group Updated: " + group.groupID + Environment.NewLine;
         }
     }
 }
コード例 #3
0
        public void CreateGetUpdateDeleteGroup()
        {
            this.InteractiveWrapper(async(MixerConnection connection, InteractiveClient interactiveClient) =>
            {
                InteractiveConnectedSceneModel testScene = await this.CreateScene(interactiveClient);

                this.ClearPackets();

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

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

                Assert.IsTrue(result);

                this.ClearPackets();

                InteractiveGroupCollectionModel groups = await interactiveClient.GetGroups();

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

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

                this.ClearPackets();

                groups = await interactiveClient.UpdateGroupsWithResponse(new List <InteractiveGroupModel>()
                {
                    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 interactiveClient.DeleteGroupWithResponse(testGroup, defaultGroup);

                Assert.IsTrue(result);

                await this.DeleteScene(interactiveClient, testScene);
            });
        }
コード例 #4
0
        protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments)
        {
            if (ChannelSession.Interactive != null && ChannelSession.Interactive.Client.Authenticated)
            {
                if (!user.Roles.Any(r => r >= this.RoleRequirement))
                {
                    if (ChannelSession.Chat != null)
                    {
                        await ChannelSession.Chat.Whisper(user.UserName, "You do not permission to perform this action.");
                    }
                    return;
                }

                if (this.group == null)
                {
                    InteractiveGroupCollectionModel groups = await ChannelSession.Interactive.GetGroups();

                    if (groups != null && groups.groups != null)
                    {
                        this.group = groups.groups.FirstOrDefault(g => g.groupID.Equals(this.GroupName));
                        if (this.group == null)
                        {
                            this.group = new InteractiveGroupModel()
                            {
                                groupID = this.GroupName, sceneID = this.SceneID
                            };
                            await ChannelSession.Interactive.CreateGroups(new List <InteractiveGroupModel>() { this.group });
                        }
                    }
                }

                if (this.InteractiveType == InteractiveActionTypeEnum.MoveGroupToScene || this.InteractiveType == InteractiveActionTypeEnum.MoveUserToScene)
                {
                    this.group.sceneID = this.SceneID;
                    await ChannelSession.Interactive.UpdateGroups(new List <InteractiveGroupModel>() { this.group });
                }

                if (this.InteractiveType == InteractiveActionTypeEnum.MoveUserToGroup || this.InteractiveType == InteractiveActionTypeEnum.MoveUserToScene)
                {
                    InteractiveParticipantModel participant = ChannelSession.Interactive.InteractiveUsers.Values.FirstOrDefault(p => p.userID.Equals(user.ID));
                    if (participant != null)
                    {
                        participant.groupID = this.GroupName;
                        await ChannelSession.Interactive.UpdateParticipants(new List <InteractiveParticipantModel>() { participant });
                    }
                }
            }
        }
コード例 #5
0
        public async Task UpdateGroup(string groupName, string sceneID)
        {
            InteractiveGroupCollectionModel groups = await ChannelSession.Interactive.GetGroups();

            if (groups != null && groups.groups != null)
            {
                InteractiveGroupModel group = groups.groups.FirstOrDefault(g => g.groupID.Equals(groupName));
                if (group != null)
                {
                    group.sceneID = sceneID;
                    await this.RunAsync(this.Client.UpdateGroups(new List <InteractiveGroupModel>()
                    {
                        group
                    }));
                }
            }
        }
コード例 #6
0
        public async Task <bool> AddGroup(string groupName, string sceneID)
        {
            InteractiveGroupCollectionModel groups = await ChannelSession.Interactive.GetGroups();

            if (groups != null && groups.groups != null)
            {
                if (!groups.groups.Any(g => g.groupID.Equals(groupName)))
                {
                    return(await this.RunAsync(this.Client.CreateGroupsWithResponse(new List <InteractiveGroupModel>()
                    {
                        new InteractiveGroupModel()
                        {
                            groupID = groupName, sceneID = sceneID
                        }
                    })));
                }
                return(true);
            }
            return(false);
        }
コード例 #7
0
 private void Client_OnGroupUpdate(object sender, InteractiveGroupCollectionModel e)
 {
     this.OnGroupUpdate(this, e);
 }