public virtual string RegisterRegion(UUID scopeID, GridRegion regionInfo, UUID SecureSessionID, out UUID SessionID)
{
SessionID = UUID.Zero;
Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
Dictionary<string, object> sendData = new Dictionary<string,object>();
foreach (KeyValuePair<string, object> kvp in rinfo)
sendData[kvp.Key] = (string)kvp.Value;
sendData["SCOPEID"] = scopeID.ToString();
sendData["SESSIONID"] = SecureSessionID.ToString();
sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
sendData["METHOD"] = "register";
string reqString = WebUtils.BuildQueryString(sendData);
// m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
try
{
string reply = SynchronousRestFormsRequester.MakeRequest("POST",
m_ServerURI + "/grid",
reqString);
if (reply != string.Empty)
{
Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);
if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
{
if (replyData.ContainsKey("Message"))
{
SessionID = UUID.Parse(replyData["Message"].ToString());
}
m_log.Info("[GridService]: Successfully registered region " + regionInfo.RegionName + " at " + regionInfo.RegionLocX + "," + regionInfo.RegionLocY + " to the grid server @ " + m_ServerURI);
return String.Empty;
}
else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure"))
{
//m_log.DebugFormat("[GRID CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString());
return replyData["Message"].ToString();
}
else if (!replyData.ContainsKey("Result"))
{
m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field");
}
else
{
m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
return "Unexpected result "+replyData["Result"].ToString();
}
}
else
m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply from " + m_ServerURI);
}
catch (Exception e)
{
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server " + m_ServerURI + " : {0}", e.Message);
}
return "Error communicating with grid service";
}