/// <summary>Raises the BannedAgents event</summary>
 /// <param name="e">An BannedAgentsEventArgs object containing the
 /// data returned from the simulator</param>
 protected virtual void OnBannedAgents(BannedAgentsEventArgs e)
 {
     EventHandler<BannedAgentsEventArgs> handler = m_BannedAgents;
     if (handler != null)
         handler(this, e);
 }
        /// <summary>
        /// Request a list of residents banned from joining a group
        /// </summary>
        /// <param name="groupID">UUID of the group</param>
        /// <param name="callback">Callback on request completition</param>
        public void RequestBannedAgents(UUID groupID, EventHandler<BannedAgentsEventArgs> callback)
        {
            Uri uri = GetGroupAPIUri(groupID);
            if (uri == null) return;

            CapsClient req = new CapsClient(uri);
            req.OnComplete += (client, result, error) =>
            {
                try
                {

                    if (error != null)
                    {
                        throw error;
                    }
                    else
                    {
                        UUID gid = ((OSDMap)result)["group_id"];
                        var banList = (OSDMap)((OSDMap)result)["ban_list"];
                        Dictionary<UUID, DateTime> bannedAgents = new Dictionary<UUID, DateTime>(banList.Count);

                        foreach (var id in banList.Keys)
                        {
                            bannedAgents[new UUID(id)] = ((OSDMap)banList[id])["ban_date"].AsDate();
                        }

                        var ret = new BannedAgentsEventArgs(groupID, true, bannedAgents);
                        OnBannedAgents(ret);
                        if (callback != null) try { callback(this, ret); }
                            catch { }
                    }

                }
                catch (Exception ex)
                {
                    Logger.Log("Failed to get a list of banned group members: " + ex.Message, Helpers.LogLevel.Warning, Client);
                    var ret = new BannedAgentsEventArgs(groupID, false, null);
                    OnBannedAgents(ret);
                    if (callback != null) try { callback(this, ret); }
                        catch { }
                }

            };

            req.BeginGetResponse(Client.Settings.CAPS_TIMEOUT);
        }