Allow retrival of multiple user records in one operation, analog to presence

iar_mods
Melanie 2012-01-16 02:19:19 +01:00
parent 59a0c50d48
commit e13a17cc0c
7 changed files with 128 additions and 2 deletions

View File

@ -171,6 +171,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
{
return m_GridUserService.GetGridUserInfo(userID);
}
public GridUserInfo[] GetGridUserInfo(string[] userID)
{
return m_GridUserService.GetGridUserInfo(userID);
}
#endregion

View File

@ -147,6 +147,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
return m_RemoteConnector.GetGridUserInfo(userID);
}
public GridUserInfo[] GetGridUserInfo(string[] userID)
{
return m_RemoteConnector.GetGridUserInfo(userID);
}
#endregion
}

View File

@ -88,6 +88,8 @@ namespace OpenSim.Server.Handlers.GridUser
return SetPosition(request);
case "getgriduserinfo":
return GetGridUserInfo(request);
case "getgriduserinfos":
return GetGridUserInfos(request);
}
m_log.DebugFormat("[GRID USER HANDLER]: unknown method request: {0}", method);
}
@ -193,6 +195,46 @@ namespace OpenSim.Server.Handlers.GridUser
}
byte[] GetGridUserInfos(Dictionary<string, object> request)
{
string[] userIDs;
if (!request.ContainsKey("AgentIDs"))
{
m_log.DebugFormat("[GRID USER HANDLER]: GetGridUserInfos called without required uuids argument");
return FailureResult();
}
if (!(request["AgentIDs"] is List<string>))
{
m_log.DebugFormat("[GRID USER HANDLER]: GetGridUserInfos input argument was of unexpected type {0}", request["uuids"].GetType().ToString());
return FailureResult();
}
userIDs = ((List<string>)request["AgentIDs"]).ToArray();
GridUserInfo[] pinfos = m_GridUserService.GetGridUserInfo(userIDs);
Dictionary<string, object> result = new Dictionary<string, object>();
if ((pinfos == null) || ((pinfos != null) && (pinfos.Length == 0)))
result["result"] = "null";
else
{
int i = 0;
foreach (GridUserInfo pinfo in pinfos)
{
Dictionary<string, object> rinfoDict = pinfo.ToKeyValuePairs();
result["griduser" + i] = rinfoDict;
i++;
}
}
string xmlString = ServerUtils.BuildXmlResponse(result);
UTF8Encoding encoding = new UTF8Encoding();
return encoding.GetBytes(xmlString);
}
private bool UnpackArgs(Dictionary<string, object> request, out string user, out UUID region, out Vector3 position, out Vector3 lookAt)
{
user = string.Empty;

View File

@ -223,5 +223,65 @@ namespace OpenSim.Services.Connectors
}
public GridUserInfo[] GetGridUserInfo(string[] userIDs)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
//sendData["SCOPEID"] = scopeID.ToString();
sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
sendData["METHOD"] = "getgriduserinfos";
sendData["AgentIDs"] = new List<string>(userIDs);
string reply = string.Empty;
string reqString = ServerUtils.BuildQueryString(sendData);
//m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
try
{
reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/griduser",
reqString);
if (reply == null || (reply != null && reply == string.Empty))
{
m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received null or empty reply");
return null;
}
}
catch (Exception e)
{
m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server: {0}", e.Message);
}
List<GridUserInfo> rinfos = new List<GridUserInfo>();
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
if (replyData != null)
{
if (replyData.ContainsKey("result") &&
(replyData["result"].ToString() == "null" || replyData["result"].ToString() == "Failure"))
{
return new GridUserInfo[0];
}
Dictionary<string, object>.ValueCollection pinfosList = replyData.Values;
//m_log.DebugFormat("[PRESENCE CONNECTOR]: GetAgents returned {0} elements", pinfosList.Count);
foreach (object griduser in pinfosList)
{
if (griduser is Dictionary<string, object>)
{
GridUserInfo pinfo = new GridUserInfo((Dictionary<string, object>)griduser);
rinfos.Add(pinfo);
}
else
m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received invalid response type {0}",
griduser.GetType());
}
}
else
m_log.DebugFormat("[GRID USER CONNECTOR]: GetGridUserInfo received null response");
return rinfos.ToArray();
}
}
}

View File

@ -472,6 +472,10 @@ namespace OpenSim.Services.Connectors.SimianGrid
return false;
}
public GridUserInfo[] GetGridUserInfo(string[] userIDs)
{
return new GridUserInfo[0];
}
#endregion Helpers
}
}

View File

@ -131,5 +131,6 @@ namespace OpenSim.Services.Interfaces
bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt);
GridUserInfo GetGridUserInfo(string userID);
GridUserInfo[] GetGridUserInfo(string[] userID);
}
}

View File

@ -73,6 +73,16 @@ namespace OpenSim.Services.UserAccountService
return info;
}
public GridUserInfo[] GetGridUserInfo(string[] userIDs)
{
List<GridUserInfo> ret = new List<GridUserInfo>();
foreach (string id in userIDs)
ret.Add(GetGridUserInfo(id));
return ret.ToArray();
}
public GridUserInfo LoggedIn(string userID)
{
m_log.DebugFormat("[GRID USER SERVICE]: User {0} is online", userID);