private GroupRequestID GetClientGroupRequestID(IClientAPI client)
        {
            if (client == null)
            {
                return new GroupRequestID();
            }

            lock (m_clientRequestIDInfo)
            {
                if (!m_clientRequestIDInfo.ContainsKey(client.AgentId))
                {
                    GroupRequestIDInfo info = new GroupRequestIDInfo();
                    info.RequestID.AgentID = client.AgentId;
                    info.RequestID.SessionID = client.SessionId;

                    //UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
                    UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId);
                    if (account == null)
                    {
                        // This should be impossible.  If I've been passed a reference to a client
                        // that client should be registered with the UserService.  So something
                        // is horribly wrong somewhere.

                        m_log.WarnFormat("[GROUPS]: Could not find a user profile for {0} / {1}", client.Name, client.AgentId);

                        // Default to local user service and hope for the best?
                        // REFACTORING PROBLEM
                        //info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;

                    }
                    else
                    {
                        string domain = string.Empty; //m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
                        object homeUriObj;
                        if (account.ServiceURLs.TryGetValue("HomeURI", out homeUriObj) && homeUriObj != null)
                            domain = homeUriObj.ToString();
                        // They're a local user, use this:
                        info.RequestID.UserServiceURL = domain;
                    }

                    m_clientRequestIDInfo.Add(client.AgentId, info);
                }

                m_clientRequestIDInfo[client.AgentId].LastUsedTMStamp = DateTime.Now;

                return m_clientRequestIDInfo[client.AgentId].RequestID;
            }
// Unreachable code!
//            return new GroupRequestID();
        }
        private GroupRequestID GetClientGroupRequestID(IClientAPI client)
        {
            if (client == null)
            {
                return new GroupRequestID();
            }

            lock (m_clientRequestIDInfo)
            {
                if (!m_clientRequestIDInfo.ContainsKey(client.AgentId))
                {
                    GroupRequestIDInfo info = new GroupRequestIDInfo();
                    info.RequestID.AgentID = client.AgentId;
                    info.RequestID.SessionID = client.SessionId;

                    UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
                    if (userProfile == null)
                    {
                        // This should be impossible.  If I've been passed a reference to a client
                        // that client should be registered with the UserService.  So something
                        // is horribly wrong somewhere.

                        m_log.WarnFormat("[GROUPS]: Could not find a user profile for {0} / {1}", client.Name, client.AgentId);

                        // Default to local user service and hope for the best?
                        info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;

                    }
                    else if (userProfile is ForeignUserProfileData)
                    {
                        // They aren't from around here
                        ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
                        info.RequestID.UserServiceURL = fupd.UserServerURI;
                    }
                    else
                    {
                        // They're a local user, use this:
                        info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
                    }

                    m_clientRequestIDInfo.Add(client.AgentId, info);
                }

                m_clientRequestIDInfo[client.AgentId].LastUsedTMStamp = DateTime.Now;
            }
            return m_clientRequestIDInfo[client.AgentId].RequestID;
        }