change ParcelPropertiesUpdate

master
UbitUmarov 2020-04-25 20:49:13 +01:00
parent d44baf20cd
commit cafe49d44b
1 changed files with 82 additions and 58 deletions

View File

@ -28,7 +28,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Net;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using log4net; using log4net;
@ -1917,6 +1917,7 @@ namespace OpenSim.Region.CoreModules.World.Land
private void EventManagerOnRegisterCaps(UUID agentID, Caps caps) private void EventManagerOnRegisterCaps(UUID agentID, Caps caps)
{ {
string cap = "/CAPS/" + UUID.Random(); string cap = "/CAPS/" + UUID.Random();
caps.RegisterHandler( caps.RegisterHandler(
"RemoteParcelRequest", "RemoteParcelRequest",
@ -1927,32 +1928,61 @@ namespace OpenSim.Region.CoreModules.World.Land
"RemoteParcelRequest", "RemoteParcelRequest",
agentID.ToString())); agentID.ToString()));
cap = "/CAPS/" + UUID.Random(); caps.RegisterSimpleHandler("ParcelPropertiesUpdate", new SimpleStreamHandler("/" + UUID.Random(),
caps.RegisterHandler( delegate (IOSHttpRequest request, IOSHttpResponse response)
"ParcelPropertiesUpdate",
new RestStreamHandler(
"POST", cap,
(request, path, param, httpRequest, httpResponse)
=> ProcessPropertiesUpdate(request, path, param, agentID, caps),
"ParcelPropertiesUpdate",
agentID.ToString()));
}
private string ProcessPropertiesUpdate(string request, string path, string param, UUID agentID, Caps caps)
{ {
ProcessPropertiesUpdate(request, response, agentID);
}));
}
private void ProcessPropertiesUpdate(IOSHttpRequest request, IOSHttpResponse response, UUID agentID)
{
if (request.HttpMethod != "POST")
{
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
IClientAPI client; IClientAPI client;
if (!m_scene.TryGetClient(agentID, out client)) if (!m_scene.TryGetClient(agentID, out client))
{ {
m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to retrieve IClientAPI for {0}", agentID); m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to retrieve IClientAPI for {0}", agentID);
return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); response.StatusCode = (int)HttpStatusCode.Gone;
return;
} }
ParcelPropertiesUpdateMessage properties = new ParcelPropertiesUpdateMessage(); OpenMetaverse.StructuredData.OSDMap args;
OpenMetaverse.StructuredData.OSDMap args = (OpenMetaverse.StructuredData.OSDMap) OSDParser.DeserializeLLSDXml(request); ParcelPropertiesUpdateMessage properties;
try
{
args = (OpenMetaverse.StructuredData.OSDMap)OSDParser.DeserializeLLSDXml(request.InputStream);
properties = new ParcelPropertiesUpdateMessage();
properties.Deserialize(args); properties.Deserialize(args);
}
catch
{
response.StatusCode = (int)HttpStatusCode.BadRequest;
return;
}
LandUpdateArgs land_update = new LandUpdateArgs();
int parcelID = properties.LocalID; int parcelID = properties.LocalID;
ILandObject land = null;
lock (m_landList)
{
m_landList.TryGetValue(parcelID, out land);
}
if (land == null)
{
m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID);
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
try
{
LandUpdateArgs land_update = new LandUpdateArgs();
land_update.AuthBuyerID = properties.AuthBuyerID; land_update.AuthBuyerID = properties.AuthBuyerID;
land_update.Category = properties.Category; land_update.Category = properties.Category;
land_update.Desc = properties.Desc; land_update.Desc = properties.Desc;
@ -1991,24 +2021,18 @@ namespace OpenSim.Region.CoreModules.World.Land
land_update.GroupAVSounds = true; land_update.GroupAVSounds = true;
} }
ILandObject land = null;
lock (m_landList)
{
m_landList.TryGetValue(parcelID, out land);
}
if (land != null)
{
UpdateLandProperties(land,land_update, client); UpdateLandProperties(land,land_update, client);
m_scene.EventManager.TriggerOnParcelPropertiesUpdateRequest(land_update, parcelID, client); m_scene.EventManager.TriggerOnParcelPropertiesUpdateRequest(land_update, parcelID, client);
} }
else catch
{ {
m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID); response.StatusCode = (int)HttpStatusCode.InternalServerError;
return;
} }
return LLSDxmlEncode.LLSDEmpty; response.StatusCode = (int)HttpStatusCode.OK;
} }
// we cheat here: As we don't have (and want) a grid-global parcel-store, we can't return the // we cheat here: As we don't have (and want) a grid-global parcel-store, we can't return the
// "real" parcelID, because we wouldn't be able to map that to the region the parcel belongs to. // "real" parcelID, because we wouldn't be able to map that to the region the parcel belongs to.
// So, we create a "fake" parcelID by using the regionHandle (64 bit), and the local (integer) x // So, we create a "fake" parcelID by using the regionHandle (64 bit), and the local (integer) x