AgentHandlers.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Specialized;
  30. using System.IO;
  31. using System.IO.Compression;
  32. using System.Reflection;
  33. using System.Net;
  34. using System.Text;
  35. using System.Web;
  36. using OpenSim.Server.Base;
  37. using OpenSim.Server.Handlers.Base;
  38. using OpenSim.Services.Interfaces;
  39. using GridRegion = OpenSim.Services.Interfaces.GridRegion;
  40. using OpenSim.Framework;
  41. using OpenSim.Framework.Servers.HttpServer;
  42. using OpenMetaverse;
  43. using OpenMetaverse.StructuredData;
  44. using Nini.Config;
  45. using log4net;
  46. namespace OpenSim.Server.Handlers.Simulation
  47. {
  48. public class AgentHandler
  49. {
  50. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  51. private ISimulationService m_SimulationService;
  52. public AgentHandler() { }
  53. public AgentHandler(ISimulationService sim)
  54. {
  55. m_SimulationService = sim;
  56. }
  57. public Hashtable Handler(Hashtable request)
  58. {
  59. // m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called");
  60. //
  61. // m_log.Debug("---------------------------");
  62. // m_log.Debug(" >> uri=" + request["uri"]);
  63. // m_log.Debug(" >> content-type=" + request["content-type"]);
  64. // m_log.Debug(" >> http-method=" + request["http-method"]);
  65. // m_log.Debug("---------------------------\n");
  66. Hashtable responsedata = new Hashtable();
  67. responsedata["content_type"] = "text/html";
  68. responsedata["keepalive"] = false;
  69. UUID agentID;
  70. UUID regionID;
  71. string action;
  72. if (!Utils.GetParams((string)request["uri"], out agentID, out regionID, out action))
  73. {
  74. m_log.InfoFormat("[AGENT HANDLER]: Invalid parameters for agent message {0}", request["uri"]);
  75. responsedata["int_response_code"] = 404;
  76. responsedata["str_response_string"] = "false";
  77. return responsedata;
  78. }
  79. // Next, let's parse the verb
  80. string method = (string)request["http-method"];
  81. if (method.Equals("DELETE"))
  82. {
  83. string auth_token = string.Empty;
  84. if (request.ContainsKey("auth"))
  85. auth_token = request["auth"].ToString();
  86. DoAgentDelete(request, responsedata, agentID, action, regionID, auth_token);
  87. return responsedata;
  88. }
  89. else if (method.Equals("QUERYACCESS"))
  90. {
  91. DoQueryAccess(request, responsedata, agentID, regionID);
  92. return responsedata;
  93. }
  94. else
  95. {
  96. m_log.ErrorFormat("[AGENT HANDLER]: method {0} not supported in agent message {1} (caller is {2})", method, (string)request["uri"], Util.GetCallerIP(request));
  97. responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed;
  98. responsedata["str_response_string"] = "Method not allowed";
  99. return responsedata;
  100. }
  101. }
  102. protected virtual void DoQueryAccess(Hashtable request, Hashtable responsedata, UUID agentID, UUID regionID)
  103. {
  104. if (m_SimulationService == null)
  105. {
  106. m_log.Debug("[AGENT HANDLER]: Agent QUERY called. Harmless but useless.");
  107. responsedata["content_type"] = "application/json";
  108. responsedata["int_response_code"] = HttpStatusCode.NotImplemented;
  109. responsedata["str_response_string"] = string.Empty;
  110. return;
  111. }
  112. // m_log.DebugFormat("[AGENT HANDLER]: Received QUERYACCESS with {0}", (string)request["body"]);
  113. OSDMap args = Utils.GetOSDMap((string)request["body"]);
  114. bool viaTeleport = true;
  115. if (args.ContainsKey("viaTeleport"))
  116. viaTeleport = args["viaTeleport"].AsBoolean();
  117. Vector3 position = Vector3.Zero;
  118. if (args.ContainsKey("position"))
  119. position = Vector3.Parse(args["position"].AsString());
  120. string agentHomeURI = null;
  121. if (args.ContainsKey("agent_home_uri"))
  122. agentHomeURI = args["agent_home_uri"].AsString();
  123. string theirVersion = string.Empty;
  124. if (args.ContainsKey("my_version"))
  125. theirVersion = args["my_version"].AsString();
  126. GridRegion destination = new GridRegion();
  127. destination.RegionID = regionID;
  128. string reason;
  129. string version;
  130. bool result = m_SimulationService.QueryAccess(destination, agentID, agentHomeURI, viaTeleport, position, theirVersion, out version, out reason);
  131. responsedata["int_response_code"] = HttpStatusCode.OK;
  132. OSDMap resp = new OSDMap(3);
  133. resp["success"] = OSD.FromBoolean(result);
  134. resp["reason"] = OSD.FromString(reason);
  135. resp["version"] = OSD.FromString(version);
  136. // We must preserve defaults here, otherwise a false "success" will not be put into the JSON map!
  137. responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp, true);
  138. // Console.WriteLine("str_response_string [{0}]", responsedata["str_response_string"]);
  139. }
  140. protected void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID, string auth_token)
  141. {
  142. if (string.IsNullOrEmpty(action))
  143. m_log.DebugFormat("[AGENT HANDLER]: >>> DELETE <<< RegionID: {0}; from: {1}; auth_code: {2}", regionID, Util.GetCallerIP(request), auth_token);
  144. else
  145. m_log.DebugFormat("[AGENT HANDLER]: Release {0} to RegionID: {1}", id, regionID);
  146. GridRegion destination = new GridRegion();
  147. destination.RegionID = regionID;
  148. if (action.Equals("release"))
  149. ReleaseAgent(regionID, id);
  150. else
  151. Util.FireAndForget(
  152. o => m_SimulationService.CloseAgent(destination, id, auth_token), null, "AgentHandler.DoAgentDelete");
  153. responsedata["int_response_code"] = HttpStatusCode.OK;
  154. responsedata["str_response_string"] = "OpenSim agent " + id.ToString();
  155. //m_log.DebugFormat("[AGENT HANDLER]: Agent {0} Released/Deleted from region {1}", id, regionID);
  156. }
  157. protected virtual void ReleaseAgent(UUID regionID, UUID id)
  158. {
  159. m_SimulationService.ReleaseAgent(regionID, id, "");
  160. }
  161. }
  162. public class AgentPostHandler : BaseStreamHandler
  163. {
  164. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  165. private ISimulationService m_SimulationService;
  166. protected bool m_Proxy = false;
  167. public AgentPostHandler(ISimulationService service) :
  168. base("POST", "/agent")
  169. {
  170. m_SimulationService = service;
  171. }
  172. public AgentPostHandler(string path) :
  173. base("POST", path)
  174. {
  175. m_SimulationService = null;
  176. }
  177. protected override byte[] ProcessRequest(string path, Stream request,
  178. IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
  179. {
  180. // m_log.DebugFormat("[SIMULATION]: Stream handler called");
  181. Hashtable keysvals = new Hashtable();
  182. Hashtable headervals = new Hashtable();
  183. string[] querystringkeys = httpRequest.QueryString.AllKeys;
  184. string[] rHeaders = httpRequest.Headers.AllKeys;
  185. keysvals.Add("uri", httpRequest.RawUrl);
  186. keysvals.Add("content-type", httpRequest.ContentType);
  187. keysvals.Add("http-method", httpRequest.HttpMethod);
  188. foreach (string queryname in querystringkeys)
  189. keysvals.Add(queryname, httpRequest.QueryString[queryname]);
  190. foreach (string headername in rHeaders)
  191. headervals[headername] = httpRequest.Headers[headername];
  192. keysvals.Add("headers", headervals);
  193. keysvals.Add("querystringkeys", querystringkeys);
  194. httpResponse.StatusCode = 200;
  195. httpResponse.ContentType = "text/html";
  196. httpResponse.KeepAlive = false;
  197. Encoding encoding = Encoding.UTF8;
  198. if (httpRequest.ContentType != "application/json")
  199. {
  200. httpResponse.StatusCode = 406;
  201. return encoding.GetBytes("false");
  202. }
  203. string requestBody;
  204. Stream inputStream = request;
  205. Stream innerStream = null;
  206. try
  207. {
  208. if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip"))
  209. {
  210. innerStream = inputStream;
  211. inputStream = new GZipStream(innerStream, CompressionMode.Decompress);
  212. }
  213. using (StreamReader reader = new StreamReader(inputStream, encoding))
  214. {
  215. requestBody = reader.ReadToEnd();
  216. }
  217. }
  218. finally
  219. {
  220. if (innerStream != null)
  221. innerStream.Dispose();
  222. inputStream.Dispose();
  223. }
  224. keysvals.Add("body", requestBody);
  225. Hashtable responsedata = new Hashtable();
  226. UUID agentID;
  227. UUID regionID;
  228. string action;
  229. if (!Utils.GetParams((string)keysvals["uri"], out agentID, out regionID, out action))
  230. {
  231. m_log.InfoFormat("[AGENT HANDLER]: Invalid parameters for agent message {0}", keysvals["uri"]);
  232. httpResponse.StatusCode = 404;
  233. return encoding.GetBytes("false");
  234. }
  235. DoAgentPost(keysvals, responsedata, agentID);
  236. httpResponse.StatusCode = (int)responsedata["int_response_code"];
  237. return encoding.GetBytes((string)responsedata["str_response_string"]);
  238. }
  239. protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
  240. {
  241. OSDMap args = Utils.GetOSDMap((string)request["body"]);
  242. if (args == null)
  243. {
  244. responsedata["int_response_code"] = HttpStatusCode.BadRequest;
  245. responsedata["str_response_string"] = "Bad request";
  246. return;
  247. }
  248. AgentDestinationData data = CreateAgentDestinationData();
  249. UnpackData(args, data, request);
  250. GridRegion destination = new GridRegion();
  251. destination.RegionID = data.uuid;
  252. destination.RegionLocX = data.x;
  253. destination.RegionLocY = data.y;
  254. destination.RegionName = data.name;
  255. GridRegion gatekeeper = ExtractGatekeeper(data);
  256. AgentCircuitData aCircuit = new AgentCircuitData();
  257. try
  258. {
  259. aCircuit.UnpackAgentCircuitData(args);
  260. }
  261. catch (Exception ex)
  262. {
  263. m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message);
  264. responsedata["int_response_code"] = HttpStatusCode.BadRequest;
  265. responsedata["str_response_string"] = "Bad request";
  266. return;
  267. }
  268. GridRegion source = null;
  269. if (args.ContainsKey("source_uuid"))
  270. {
  271. source = new GridRegion();
  272. source.RegionLocX = Int32.Parse(args["source_x"].AsString());
  273. source.RegionLocY = Int32.Parse(args["source_y"].AsString());
  274. source.RegionName = args["source_name"].AsString();
  275. source.RegionID = UUID.Parse(args["source_uuid"].AsString());
  276. if (args.ContainsKey("source_server_uri"))
  277. source.RawServerURI = args["source_server_uri"].AsString();
  278. else
  279. source.RawServerURI = null;
  280. }
  281. OSDMap resp = new OSDMap(2);
  282. string reason = String.Empty;
  283. // This is the meaning of POST agent
  284. //m_regionClient.AdjustUserInformation(aCircuit);
  285. //bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason);
  286. bool result = CreateAgent(source, gatekeeper, destination, aCircuit, data.flags, data.fromLogin, out reason);
  287. resp["reason"] = OSD.FromString(reason);
  288. resp["success"] = OSD.FromBoolean(result);
  289. // Let's also send out the IP address of the caller back to the caller (HG 1.5)
  290. resp["your_ip"] = OSD.FromString(GetCallerIP(request));
  291. // TODO: add reason if not String.Empty?
  292. responsedata["int_response_code"] = HttpStatusCode.OK;
  293. responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
  294. }
  295. protected virtual AgentDestinationData CreateAgentDestinationData()
  296. {
  297. return new AgentDestinationData();
  298. }
  299. protected virtual void UnpackData(OSDMap args, AgentDestinationData data, Hashtable request)
  300. {
  301. // retrieve the input arguments
  302. if (args.ContainsKey("destination_x") && args["destination_x"] != null)
  303. Int32.TryParse(args["destination_x"].AsString(), out data.x);
  304. else
  305. m_log.WarnFormat(" -- request didn't have destination_x");
  306. if (args.ContainsKey("destination_y") && args["destination_y"] != null)
  307. Int32.TryParse(args["destination_y"].AsString(), out data.y);
  308. else
  309. m_log.WarnFormat(" -- request didn't have destination_y");
  310. if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
  311. UUID.TryParse(args["destination_uuid"].AsString(), out data.uuid);
  312. if (args.ContainsKey("destination_name") && args["destination_name"] != null)
  313. data.name = args["destination_name"].ToString();
  314. if (args.ContainsKey("teleport_flags") && args["teleport_flags"] != null)
  315. data.flags = args["teleport_flags"].AsUInteger();
  316. }
  317. protected virtual GridRegion ExtractGatekeeper(AgentDestinationData data)
  318. {
  319. return null;
  320. }
  321. protected string GetCallerIP(Hashtable request)
  322. {
  323. if (!m_Proxy)
  324. return Util.GetCallerIP(request);
  325. // We're behind a proxy
  326. Hashtable headers = (Hashtable)request["headers"];
  327. //// DEBUG
  328. //foreach (object o in headers.Keys)
  329. // m_log.DebugFormat("XXX {0} = {1}", o.ToString(), (headers[o] == null? "null" : headers[o].ToString()));
  330. string xff = "X-Forwarded-For";
  331. if (headers.ContainsKey(xff.ToLower()))
  332. xff = xff.ToLower();
  333. if (!headers.ContainsKey(xff) || headers[xff] == null)
  334. {
  335. m_log.WarnFormat("[AGENT HANDLER]: No XFF header");
  336. return Util.GetCallerIP(request);
  337. }
  338. m_log.DebugFormat("[AGENT HANDLER]: XFF is {0}", headers[xff]);
  339. IPEndPoint ep = Util.GetClientIPFromXFF((string)headers[xff]);
  340. if (ep != null)
  341. return ep.Address.ToString();
  342. // Oops
  343. return Util.GetCallerIP(request);
  344. }
  345. // subclasses can override this
  346. protected virtual bool CreateAgent(GridRegion source, GridRegion gatekeeper, GridRegion destination,
  347. AgentCircuitData aCircuit, uint teleportFlags, bool fromLogin, out string reason)
  348. {
  349. return m_SimulationService.CreateAgent(source, destination, aCircuit, teleportFlags, out reason);
  350. }
  351. }
  352. public class AgentPutHandler : BaseStreamHandler
  353. {
  354. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  355. private ISimulationService m_SimulationService;
  356. protected bool m_Proxy = false;
  357. public AgentPutHandler(ISimulationService service) :
  358. base("PUT", "/agent")
  359. {
  360. m_SimulationService = service;
  361. }
  362. public AgentPutHandler(string path) :
  363. base("PUT", path)
  364. {
  365. m_SimulationService = null;
  366. }
  367. protected override byte[] ProcessRequest(string path, Stream request,
  368. IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
  369. {
  370. // m_log.DebugFormat("[SIMULATION]: Stream handler called");
  371. Hashtable keysvals = new Hashtable();
  372. Hashtable headervals = new Hashtable();
  373. string[] querystringkeys = httpRequest.QueryString.AllKeys;
  374. string[] rHeaders = httpRequest.Headers.AllKeys;
  375. keysvals.Add("uri", httpRequest.RawUrl);
  376. keysvals.Add("content-type", httpRequest.ContentType);
  377. keysvals.Add("http-method", httpRequest.HttpMethod);
  378. foreach (string queryname in querystringkeys)
  379. keysvals.Add(queryname, httpRequest.QueryString[queryname]);
  380. foreach (string headername in rHeaders)
  381. headervals[headername] = httpRequest.Headers[headername];
  382. keysvals.Add("headers", headervals);
  383. keysvals.Add("querystringkeys", querystringkeys);
  384. String requestBody;
  385. Encoding encoding = Encoding.UTF8;
  386. Stream inputStream = request;
  387. Stream innerStream = null;
  388. try
  389. {
  390. if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip"))
  391. {
  392. innerStream = inputStream;
  393. inputStream = new GZipStream(innerStream, CompressionMode.Decompress);
  394. }
  395. using (StreamReader reader = new StreamReader(inputStream, encoding))
  396. {
  397. requestBody = reader.ReadToEnd();
  398. }
  399. }
  400. finally
  401. {
  402. if (innerStream != null)
  403. innerStream.Dispose();
  404. inputStream.Dispose();
  405. }
  406. keysvals.Add("body", requestBody);
  407. httpResponse.StatusCode = 200;
  408. httpResponse.ContentType = "text/html";
  409. httpResponse.KeepAlive = false;
  410. Hashtable responsedata = new Hashtable();
  411. UUID agentID;
  412. UUID regionID;
  413. string action;
  414. if (!Utils.GetParams((string)keysvals["uri"], out agentID, out regionID, out action))
  415. {
  416. m_log.InfoFormat("[AGENT HANDLER]: Invalid parameters for agent message {0}", keysvals["uri"]);
  417. httpResponse.StatusCode = 404;
  418. return encoding.GetBytes("false");
  419. }
  420. DoAgentPut(keysvals, responsedata);
  421. httpResponse.StatusCode = (int)responsedata["int_response_code"];
  422. return encoding.GetBytes((string)responsedata["str_response_string"]);
  423. }
  424. protected void DoAgentPut(Hashtable request, Hashtable responsedata)
  425. {
  426. OSDMap args = Utils.GetOSDMap((string)request["body"]);
  427. if (args == null)
  428. {
  429. responsedata["int_response_code"] = HttpStatusCode.BadRequest;
  430. responsedata["str_response_string"] = "Bad request";
  431. return;
  432. }
  433. // retrieve the input arguments
  434. int x = 0, y = 0;
  435. UUID uuid = UUID.Zero;
  436. string regionname = string.Empty;
  437. if (args.ContainsKey("destination_x") && args["destination_x"] != null)
  438. Int32.TryParse(args["destination_x"].AsString(), out x);
  439. if (args.ContainsKey("destination_y") && args["destination_y"] != null)
  440. Int32.TryParse(args["destination_y"].AsString(), out y);
  441. if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
  442. UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
  443. if (args.ContainsKey("destination_name") && args["destination_name"] != null)
  444. regionname = args["destination_name"].ToString();
  445. GridRegion destination = new GridRegion();
  446. destination.RegionID = uuid;
  447. destination.RegionLocX = x;
  448. destination.RegionLocY = y;
  449. destination.RegionName = regionname;
  450. string messageType;
  451. if (args["message_type"] != null)
  452. messageType = args["message_type"].AsString();
  453. else
  454. {
  455. m_log.Warn("[AGENT HANDLER]: Agent Put Message Type not found. ");
  456. messageType = "AgentData";
  457. }
  458. bool result = true;
  459. if ("AgentData".Equals(messageType))
  460. {
  461. AgentData agent = new AgentData();
  462. try
  463. {
  464. agent.Unpack(args, m_SimulationService.GetScene(destination.RegionID));
  465. }
  466. catch (Exception ex)
  467. {
  468. m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
  469. responsedata["int_response_code"] = HttpStatusCode.BadRequest;
  470. responsedata["str_response_string"] = "Bad request";
  471. return;
  472. }
  473. //agent.Dump();
  474. // This is one of the meanings of PUT agent
  475. result = UpdateAgent(destination, agent);
  476. }
  477. else if ("AgentPosition".Equals(messageType))
  478. {
  479. AgentPosition agent = new AgentPosition();
  480. try
  481. {
  482. agent.Unpack(args, m_SimulationService.GetScene(destination.RegionID));
  483. }
  484. catch (Exception ex)
  485. {
  486. m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
  487. return;
  488. }
  489. //agent.Dump();
  490. // This is one of the meanings of PUT agent
  491. result = m_SimulationService.UpdateAgent(destination, agent);
  492. }
  493. responsedata["int_response_code"] = HttpStatusCode.OK;
  494. responsedata["str_response_string"] = result.ToString();
  495. //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead
  496. }
  497. // subclasses can override this
  498. protected virtual bool UpdateAgent(GridRegion destination, AgentData agent)
  499. {
  500. return m_SimulationService.UpdateAgent(destination, agent);
  501. }
  502. }
  503. public class AgentDestinationData
  504. {
  505. public int x;
  506. public int y;
  507. public string name;
  508. public UUID uuid;
  509. public uint flags;
  510. public bool fromLogin;
  511. }
  512. }