aaaaaaarrrrrrrrrggggghhhhhhhh why oh why?
parent
1a28ef6292
commit
cc53580ba4
|
@ -109,8 +109,11 @@ namespace OpenGridServices.GridServer
|
||||||
|
|
||||||
httpServer.AddXmlRPCHandler("simulator_login", m_simProfileManager.XmlRpcLoginToSimulatorMethod);
|
httpServer.AddXmlRPCHandler("simulator_login", m_simProfileManager.XmlRpcLoginToSimulatorMethod);
|
||||||
|
|
||||||
httpServer.AddRestHandler("GET", "/sims/", m_simProfileManager.RestGetSimMethod);
|
httpServer.AddRestHandler("GET", "/sims", m_simProfileManager.RestGetSimMethod);
|
||||||
httpServer.AddRestHandler("POST", "/sims/", m_simProfileManager.RestSetSimMethod);
|
httpServer.AddRestHandler("POST", "/sims", m_simProfileManager.RestSetSimMethod);
|
||||||
|
httpServer.AddRestHandler("GET", "/regions", m_simProfileManager.RestGetRegionMethod);
|
||||||
|
httpServer.AddRestHandler("POST", "/regions", m_simProfileManager.RestSetRegionMethod);
|
||||||
|
|
||||||
|
|
||||||
// lbsa71 : This code snippet taken from old http server.
|
// lbsa71 : This code snippet taken from old http server.
|
||||||
// I have no idea what this was supposed to do - looks like an infinite recursion to me.
|
// I have no idea what this was supposed to do - looks like an infinite recursion to me.
|
||||||
|
|
|
@ -186,52 +186,33 @@ namespace OpenGridServices.GridServer
|
||||||
|
|
||||||
public string RestSetSimMethod(string request, string path, string param)
|
public string RestSetSimMethod(string request, string path, string param)
|
||||||
{
|
{
|
||||||
string respstring = String.Empty;
|
Console.WriteLine("SimProfiles.cs:RestSetSimMethod() - processing request......");
|
||||||
|
|
||||||
SimProfileBase TheSim;
|
SimProfileBase TheSim;
|
||||||
LLUUID UUID = new LLUUID(param);
|
LLUUID UUID = new LLUUID(param);
|
||||||
TheSim = GetProfileByLLUUID(UUID);
|
TheSim = GetProfileByLLUUID(UUID);
|
||||||
|
if ((TheSim) == null) TheSim = new SimProfileBase();
|
||||||
|
|
||||||
if (!(TheSim == null))
|
|
||||||
{
|
|
||||||
Console.WriteLine("Updating sim details.....");
|
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
doc.LoadXml(request);
|
doc.LoadXml(request);
|
||||||
XmlNode authkeynode = doc.FirstChild;
|
XmlNode authkeynode = doc.FirstChild;
|
||||||
if (authkeynode.Name != "authkey")
|
if (authkeynode.Name != "authkey")
|
||||||
{
|
{
|
||||||
respstring = "ERROR! bad XML - expected authkey tag";
|
return "ERROR! bad XML - expected authkey tag";
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
XmlNode simnode = doc.ChildNodes[1];
|
XmlNode simnode = doc.ChildNodes[1];
|
||||||
if (simnode.Name != "sim")
|
if (simnode.Name != "sim")
|
||||||
{
|
{
|
||||||
respstring = "ERROR! bad XML - expected sim tag";
|
return "ERROR! bad XML - expected sim tag";
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (authkeynode.Name != m_gridManager.SimRecvKey)
|
|
||||||
{
|
|
||||||
respstring = "ERROR! invalid key";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (TheSim == null)
|
|
||||||
{
|
|
||||||
respstring = "ERROR! sim not found";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int i = 0; i <= simnode.ChildNodes.Count; i++)
|
|
||||||
{
|
|
||||||
switch (simnode.ChildNodes[i].Name)
|
|
||||||
{
|
|
||||||
case "uuid":
|
|
||||||
// should a sim be able to update it's own UUID? To be decided
|
|
||||||
// watch next week for the exciting conclusion in "the adventures of OpenGridServices.GridServer/GridHttp.cs:ParseREST() at line 190!
|
|
||||||
break; // and line 190's arch-enemy - THE BREAK STATEMENT! OH NOES!!!!! (this code written at 6:57AM, no sleep, lots of caffeine)
|
|
||||||
|
|
||||||
|
if (authkeynode.InnerText != m_gridManager.SimRecvKey)
|
||||||
|
{
|
||||||
|
return "ERROR! invalid key";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i <= simnode.ChildNodes.Count; i++) {
|
||||||
|
switch (simnode.ChildNodes[i].Name) {
|
||||||
case "regionname":
|
case "regionname":
|
||||||
TheSim.regionname = simnode.ChildNodes[i].InnerText;
|
TheSim.regionname = simnode.ChildNodes[i].InnerText;
|
||||||
break;
|
break;
|
||||||
|
@ -255,14 +236,19 @@ namespace OpenGridServices.GridServer
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
respstring = "OK";
|
return "OK";
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return respstring;
|
public string RestGetRegionMethod(string request, string path, string param )
|
||||||
|
{
|
||||||
|
SimProfileBase TheSim = GetProfileByHandle((ulong)Convert.ToUInt64(param));
|
||||||
|
return RestGetSimMethod("", "/sims/", param);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string RestSetRegionMethod(string request, string path, string param )
|
||||||
|
{
|
||||||
|
SimProfileBase TheSim = GetProfileByHandle((ulong)Convert.ToUInt64(param));
|
||||||
|
return RestSetSimMethod("", "/sims/", param);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string RestGetSimMethod(string request, string path, string param )
|
public string RestGetSimMethod(string request, string path, string param )
|
||||||
|
|
|
@ -55,18 +55,22 @@ namespace OpenSim
|
||||||
reqtext += "<estate_id>1</estate_id>";
|
reqtext += "<estate_id>1</estate_id>";
|
||||||
reqtext += "</sim>";
|
reqtext += "</sim>";
|
||||||
|
|
||||||
|
byte[] reqdata = (new System.Text.ASCIIEncoding()).GetBytes(reqtext);
|
||||||
|
|
||||||
WebRequest GridSaveReq = WebRequest.Create(this.GridURL + "sims/" + this.SimUUID.ToString());
|
WebRequest GridSaveReq = WebRequest.Create(this.GridURL + "sims/" + this.SimUUID.ToString());
|
||||||
GridSaveReq.Method = "POST";
|
GridSaveReq.Method = "POST";
|
||||||
GridSaveReq.ContentType = "text/plaintext";
|
GridSaveReq.ContentType = "application/x-www-form-urlencoded";
|
||||||
GridSaveReq.ContentLength = reqtext.Length;
|
GridSaveReq.ContentLength = reqdata.Length;
|
||||||
|
|
||||||
StreamWriter stOut = new StreamWriter(GridSaveReq.GetRequestStream(), System.Text.Encoding.ASCII);
|
Stream stOut = GridSaveReq.GetRequestStream();
|
||||||
stOut.Write(reqtext);
|
stOut.Write(reqdata,0,reqdata.Length);
|
||||||
stOut.Close();
|
stOut.Close();
|
||||||
|
|
||||||
StreamReader stIn = new StreamReader(GridSaveReq.GetResponse().GetResponseStream());
|
WebResponse gridresp = GridSaveReq.GetResponse();
|
||||||
|
StreamReader stIn = new StreamReader(gridresp.GetResponseStream());
|
||||||
string GridResponse = stIn.ReadToEnd();
|
string GridResponse = stIn.ReadToEnd();
|
||||||
stIn.Close();
|
stIn.Close();
|
||||||
|
gridresp.Close();
|
||||||
|
|
||||||
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("RegionInfo.CS:SaveToGrid() - Grid said: " + GridResponse);
|
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("RegionInfo.CS:SaveToGrid() - Grid said: " + GridResponse);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue