Skip to content

Instantly share code, notes, and snippets.

@TechplexEngineer
Created July 6, 2014 17:41
Show Gist options
  • Select an option

  • Save TechplexEngineer/12e30284067111777d84 to your computer and use it in GitHub Desktop.

Select an option

Save TechplexEngineer/12e30284067111777d84 to your computer and use it in GitHub Desktop.
How to find any Hypergrid user's UUID Per: http://opensimulator.org/pipermail/opensim-dev/2013-December/024480.html -- LibOpenMetaverse required
using System;
using OpenMetaverse;
using System.Collections;
using Nwc.XmlRpc;
namespace Name2Key
{
class MainClass
{
static string m_ServerURL = "http://grid.kitely.com:8002/user/";//"http://hg.osgrid.org:80/user/";
static string m_ServerURLHost = m_ServerURL;
public static void Main (string[] args)
{
Console.WriteLine ("Hello World! {0}", GetUUID("Techplex", "Engineer"));
}
public static UUID GetUUID(String first, String last)
{
Hashtable hash = new Hashtable();
hash["first"] = first;
hash["last"] = last;
hash = CallServer("get_uuid", hash);
if (!hash.ContainsKey("UUID"))
{
throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} didn't return a UUID", m_ServerURLHost));
}
UUID uuid;
if (!UUID.TryParse(hash["UUID"].ToString(), out uuid))
{
throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} returned an invalid UUID: {1}", m_ServerURLHost, hash["UUID"].ToString()));
}
return uuid;
}
private static Hashtable CallServer(string methodName, Hashtable hash)
{
IList paramList = new ArrayList();
paramList.Add(hash);
XmlRpcRequest request = new XmlRpcRequest(methodName, paramList);
// Send and get reply
XmlRpcResponse response = null;
try
{
response = request.Send(m_ServerURL, 10000);
}
catch (Exception e)
{
Console.WriteLine("[USER AGENT CONNECTOR]: {0} call to {1} failed: {2}", methodName, m_ServerURLHost, e.Message);
throw;
}
if (response.IsFault)
{
throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned an error: {2}", methodName, m_ServerURLHost, response.FaultString));
}
hash = (Hashtable)response.Value;
if (hash == null)
{
throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned null", methodName, m_ServerURLHost));
}
return hash;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment