public override string Execute(string[] args, UUID fromAgentID)
        {
            if (args.Length < 1)
            {
                return(Description);
            }

            groups.Clear();
            activeGroup = string.Empty;

            string groupName = String.Empty;

            for (int i = 0; i < args.Length; i++)
            {
                groupName += args[i] + " ";
            }
            groupName = groupName.Trim();

            GroupManager.CurrentGroupsCallback callback = new GroupManager.CurrentGroupsCallback(Groups_OnCurrentGroups);
            Client.Groups.OnCurrentGroups += callback;
            Client.Groups.RequestCurrentGroups();

            GroupsEvent.WaitOne(30000, false);

            Client.Groups.OnCurrentGroups -= callback;
            GroupsEvent.Reset();

            if (groups.Count > 0)
            {
                foreach (Group currentGroup in groups.Values)
                {
                    if (currentGroup.Name.ToLower() == groupName.ToLower())
                    {
                        NetworkManager.PacketCallback pcallback = new NetworkManager.PacketCallback(AgentDataUpdateHandler);
                        Client.Network.RegisterCallback(PacketType.AgentDataUpdate, pcallback);

                        Console.WriteLine("setting " + currentGroup.Name + " as active group");
                        Client.Groups.ActivateGroup(currentGroup.ID);
                        GroupsEvent.WaitOne(30000, false);

                        Client.Network.UnregisterCallback(PacketType.AgentDataUpdate, pcallback);
                        GroupsEvent.Reset();

                        /* A.Biondi
                         * TODO: Handle titles choosing.
                         */

                        if (String.IsNullOrEmpty(activeGroup))
                        {
                            return(Client.ToString() + " failed to activate the group " + groupName);
                        }

                        return("Active group is now " + activeGroup);
                    }
                }
                return(Client.ToString() + " doesn't seem to be member of the group " + groupName);
            }

            return(Client.ToString() + " doesn't seem member of any group");
        }
Exemplo n.º 2
0
        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length < 1)
                return Description;

            groups.Clear();

            string groupName = String.Empty;
            for (int i = 0; i < args.Length; i++)
                groupName += args[i] + " ";
            groupName = groupName.Trim();

            GroupManager.CurrentGroupsCallback callback = new GroupManager.CurrentGroupsCallback(Groups_OnCurrentGroups);
            Client.Groups.OnCurrentGroups += callback;
            Client.Groups.RequestCurrentGroups();

            GroupsEvent.WaitOne(30000, false);

            Client.Groups.OnCurrentGroups -= callback;
            GroupsEvent.Reset();

            if (groups.Count > 0)
            {
                foreach (Group currentGroup in groups.Values)
                    if (currentGroup.Name.ToLower() == groupName.ToLower())
                    {
                        GroupManager.GroupLeftCallback lcallback = new GroupManager.GroupLeftCallback(Groups_OnGroupLeft);
                        Client.Groups.OnGroupLeft += lcallback;
                        Client.Groups.LeaveGroup(currentGroup.ID);

                        /* A.Biondi 
                         * TODO: modify GroupsCommand.cs
                         * GroupsCommand.cs doesn't refresh the groups list until a new
                         * CurrentGroupsCallback occurs, so if you'd issue the command
                         * 'Groups' right after have left a group, it'll display still yet 
                         * the group you just left (unless you have 0 groups, because it 
                         * would force the refresh with Client.Groups.RequestCurrentGroups).
                         */

                        GroupsEvent.WaitOne(30000, false);

                        Client.Groups.OnGroupLeft -= lcallback;
                        GroupsEvent.Reset();

                        if (leftGroup)
                            return Client.ToString() + " has left the group " + groupName;
                        return "failed to left the group " + groupName;
                    }
                return Client.ToString() + " doesn't seem to be member of the group " + groupName;
            }

            return Client.ToString() + " doesn't seem member of any group";
        }
        public override string Execute(string[] args, UUID fromAgentID)
        {
            if (args.Length < 1)
                return Description;

            groups.Clear();
            activeGroup = string.Empty;

            string groupName = String.Empty;
            for (int i = 0; i < args.Length; i++)
                groupName += args[i] + " ";
            groupName = groupName.Trim();

            GroupManager.CurrentGroupsCallback callback = new GroupManager.CurrentGroupsCallback(Groups_OnCurrentGroups);
            Client.Groups.OnCurrentGroups += callback;
            Client.Groups.RequestCurrentGroups();

            GroupsEvent.WaitOne(30000, false);

            Client.Groups.OnCurrentGroups -= callback;
            GroupsEvent.Reset();

            if (groups.Count > 0)
            {
                foreach (Group currentGroup in groups.Values)
                    if (currentGroup.Name.ToLower() == groupName.ToLower())
                    {
                        NetworkManager.PacketCallback pcallback = new NetworkManager.PacketCallback(AgentDataUpdateHandler);
                        Client.Network.RegisterCallback(PacketType.AgentDataUpdate, pcallback);

                        Console.WriteLine("setting " + currentGroup.Name + " as active group");
                        Client.Groups.ActivateGroup(currentGroup.ID);
                        GroupsEvent.WaitOne(30000, false);

                        Client.Network.UnregisterCallback(PacketType.AgentDataUpdate, pcallback);
                        GroupsEvent.Reset();

                        /* A.Biondi
                         * TODO: Handle titles choosing.
                         */

                        if (String.IsNullOrEmpty(activeGroup))
                            return Client.ToString() + " failed to activate the group " + groupName;

                        return "Active group is now " + activeGroup;
                    }
                return Client.ToString() + " doesn't seem to be member of the group " + groupName;
            }

            return Client.ToString() + " doesn't seem member of any group";
        }
Exemplo n.º 4
0
        public override string Execute(string[] args, UUID fromAgentID)
        {
            if (args.Length < 1)
            {
                return(Description);
            }

            groups.Clear();

            string groupName = String.Empty;

            for (int i = 0; i < args.Length; i++)
            {
                groupName += args[i] + " ";
            }
            groupName = groupName.Trim();

            GroupManager.CurrentGroupsCallback callback = new GroupManager.CurrentGroupsCallback(Groups_OnCurrentGroups);
            Client.Groups.OnCurrentGroups += callback;
            Client.Groups.RequestCurrentGroups();

            GroupsEvent.WaitOne(30000, false);

            Client.Groups.OnCurrentGroups -= callback;
            GroupsEvent.Reset();

            if (groups.Count > 0)
            {
                foreach (Group currentGroup in groups.Values)
                {
                    if (currentGroup.Name.ToLower() == groupName.ToLower())
                    {
                        GroupManager.GroupLeftCallback lcallback = new GroupManager.GroupLeftCallback(Groups_OnGroupLeft);
                        Client.Groups.OnGroupLeft += lcallback;
                        Client.Groups.LeaveGroup(currentGroup.ID);

                        /* A.Biondi
                         * TODO: modify GroupsCommand.cs
                         * GroupsCommand.cs doesn't refresh the groups list until a new
                         * CurrentGroupsCallback occurs, so if you'd issue the command
                         * 'Groups' right after have left a group, it'll display still yet
                         * the group you just left (unless you have 0 groups, because it
                         * would force the refresh with Client.Groups.RequestCurrentGroups).
                         */

                        GroupsEvent.WaitOne(30000, false);

                        Client.Groups.OnGroupLeft -= lcallback;
                        GroupsEvent.Reset();

                        if (leftGroup)
                        {
                            return(Client.ToString() + " has left the group " + groupName);
                        }
                        return("failed to left the group " + groupName);
                    }
                }
                return(Client.ToString() + " doesn't seem to be member of the group " + groupName);
            }

            return(Client.ToString() + " doesn't seem member of any group");
        }
Exemplo n.º 5
0
 public void ReloadGroupsCache()
 {
     GroupManager.CurrentGroupsCallback callback =
             new GroupManager.CurrentGroupsCallback(Groups_OnCurrentGroups);
     Groups.OnCurrentGroups += callback;
     Groups.RequestCurrentGroups();
     GroupsEvent.WaitOne(10000, false);
     Groups.OnCurrentGroups -= callback;
     GroupsEvent.Reset();
 }