mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 09:16:28 +08:00
* Sugilite user server can now return user profile information by account name (Hi MingChen) - uses the REST GET /user/name/ method.
This commit is contained in:
Binary file not shown.
@@ -53,9 +53,7 @@ namespace OpenGridServices.UserServer
|
||||
private UserConfig Cfg;
|
||||
protected IGenericConfig localXMLConfig;
|
||||
|
||||
public UserManager m_userManager; // Replaces below.
|
||||
|
||||
//private UserProfileManager m_userProfileManager; // Depreciated
|
||||
public UserManager m_userManager;
|
||||
|
||||
public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
|
||||
|
||||
@@ -64,7 +62,7 @@ namespace OpenGridServices.UserServer
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Starting...\n");
|
||||
Console.WriteLine("Launching UserServer...");
|
||||
|
||||
OpenUser_Main userserver = new OpenUser_Main();
|
||||
|
||||
@@ -108,9 +106,11 @@ namespace OpenGridServices.UserServer
|
||||
BaseHttpServer httpServer = new BaseHttpServer(8002);
|
||||
|
||||
httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod);
|
||||
httpServer.AddRestHandler("GET", "/user/name/", m_userManager.RestGetUserMethodName);
|
||||
httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod);
|
||||
|
||||
httpServer.Start();
|
||||
m_console.Status("Userserver 0.3 - Startup complete");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -655,5 +655,56 @@ namespace OpenGridServices.UserServer
|
||||
return "OK";
|
||||
}
|
||||
|
||||
public string CreateUnknownUserErrorResponse()
|
||||
{
|
||||
return "<error>Unknown user</error>";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a user profile to an XML element which can be returned
|
||||
/// </summary>
|
||||
/// <param name="profile">The user profile</param>
|
||||
/// <returns>A string containing an XML Document of the user profile</returns>
|
||||
public string ProfileToXml(UserProfileData profile)
|
||||
{
|
||||
System.IO.StringWriter sw = new System.IO.StringWriter();
|
||||
XmlTextWriter xw = new XmlTextWriter(sw);
|
||||
|
||||
// Header
|
||||
xw.Formatting = Formatting.Indented;
|
||||
xw.WriteStartDocument();
|
||||
xw.WriteDocType("userprofile", null, null, null);
|
||||
xw.WriteComment("Found user profiles matching the request");
|
||||
xw.WriteStartElement("users");
|
||||
|
||||
// User
|
||||
xw.WriteStartElement("user");
|
||||
xw.WriteAttributeString("firstname", profile.username);
|
||||
xw.WriteAttributeString("lastname", profile.surname);
|
||||
xw.WriteAttributeString("uuid", profile.UUID.ToStringHyphenated());
|
||||
xw.WriteAttributeString("inventory", profile.userInventoryURI);
|
||||
xw.WriteAttributeString("asset", profile.userAssetURI);
|
||||
xw.WriteEndElement();
|
||||
|
||||
// Footer
|
||||
xw.WriteEndElement();
|
||||
xw.Flush();
|
||||
xw.Close();
|
||||
|
||||
return sw.ToString();
|
||||
}
|
||||
|
||||
public string RestGetUserMethodName(string request, string path, string param)
|
||||
{
|
||||
UserProfileData userProfile = getUserProfile(param.Trim());
|
||||
|
||||
if (userProfile == null)
|
||||
{
|
||||
return CreateUnknownUserErrorResponse();
|
||||
}
|
||||
|
||||
return ProfileToXml(userProfile);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user