Aurora.Addon.HyperGrid.UserAgentServiceConnector.GetServerURLs C# (CSharp) Метод

GetServerURLs() публичный Метод

public GetServerURLs ( UUID userID ) : object>.Dictionary
userID UUID
Результат object>.Dictionary
        public Dictionary<string, object> GetServerURLs(UUID userID)
        {
            Hashtable hash = new Hashtable ();
            hash["userID"] = userID.ToString ();

            IList paramList = new ArrayList ();
            paramList.Add (hash);

            XmlRpcRequest request = new XmlRpcRequest ("get_server_urls", paramList);
            string reason = string.Empty;

            // Send and get reply
            Dictionary<string, object> serverURLs = new Dictionary<string, object> ();
            XmlRpcResponse response = null;
            try
            {
                response = request.Send (m_ServerURL, 10000);
            }
            catch (Exception e)
            {
                MainConsole.Instance.DebugFormat ("[USER AGENT CONNECTOR]: Unable to contact remote server {0}", m_ServerURL);
                reason = "Exception: " + e.Message;
                return serverURLs;
            }

            if (response.IsFault)
            {
                MainConsole.Instance.ErrorFormat ("[USER AGENT CONNECTOR]: remote call to {0} returned an error: {1}", m_ServerURL, response.FaultString);
                reason = "XMLRPC Fault";
                return serverURLs;
            }

            hash = (Hashtable)response.Value;
            //foreach (Object o in hash)
            //    MainConsole.Instance.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
            try
            {
                if (hash == null)
                {
                    MainConsole.Instance.ErrorFormat ("[USER AGENT CONNECTOR]: GetServerURLs Got null response from {0}! THIS IS BAAAAD", m_ServerURL);
                    reason = "Internal error 1";
                    return serverURLs;
                }

                // Here is the actual response
                foreach (object key in hash.Keys)
                {
                    if (key is string && ((string)key).StartsWith ("SRV_") && hash[key] != null)
                    {
                        string serverType = key.ToString ().Substring (4); // remove "SRV_"
                        serverURLs.Add (serverType, hash[key].ToString ());
                    }
                }

            }
            catch (Exception e)
            {
                MainConsole.Instance.ErrorFormat ("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response.");
                reason = "Exception: " + e.Message;
            }

            return serverURLs;
        }

Usage Example

        public string GetUserServerURL(UUID userID, string serverType)
        {
            UserData userdata;

            if (GetUserData(userID, out userdata))
            {
                if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
                {
                    return(userdata.ServerURLs[serverType].ToString());
                }

                if (userdata.HomeURL != string.Empty)
                {
                    UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL);
                    userdata.ServerURLs = uConn.GetServerURLs(userID);
                    if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
                    {
                        return(userdata.ServerURLs[serverType].ToString());
                    }
                }
            }

            return(string.Empty);
        }
All Usage Examples Of Aurora.Addon.HyperGrid.UserAgentServiceConnector::GetServerURLs