diff options
author | Melanie | 2011-05-08 23:23:33 +0200 |
---|---|---|
committer | Melanie | 2011-05-08 23:52:31 +0100 |
commit | c8b955803953e46f5695d3faac1f363406074ffa (patch) | |
tree | 33068067e6ba058f18c8dad9da5d44221769e631 /OpenSim/Server/Handlers/Simulation | |
parent | Remove a spammy debug I left in. Disable TP cancel button at the point (diff) | |
download | opensim-SC_OLD-c8b955803953e46f5695d3faac1f363406074ffa.zip opensim-SC_OLD-c8b955803953e46f5695d3faac1f363406074ffa.tar.gz opensim-SC_OLD-c8b955803953e46f5695d3faac1f363406074ffa.tar.bz2 opensim-SC_OLD-c8b955803953e46f5695d3faac1f363406074ffa.tar.xz |
Also compress the actual fatpacks
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 264 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs | 1 |
2 files changed, 171 insertions, 94 deletions
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 21b26df..379924f 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |||
@@ -90,12 +90,7 @@ namespace OpenSim.Server.Handlers.Simulation | |||
90 | 90 | ||
91 | // Next, let's parse the verb | 91 | // Next, let's parse the verb |
92 | string method = (string)request["http-method"]; | 92 | string method = (string)request["http-method"]; |
93 | if (method.Equals("PUT")) | 93 | if (method.Equals("GET")) |
94 | { | ||
95 | DoAgentPut(request, responsedata); | ||
96 | return responsedata; | ||
97 | } | ||
98 | else if (method.Equals("GET")) | ||
99 | { | 94 | { |
100 | DoAgentGet(request, responsedata, agentID, regionID); | 95 | DoAgentGet(request, responsedata, agentID, regionID); |
101 | return responsedata; | 96 | return responsedata; |
@@ -121,94 +116,6 @@ namespace OpenSim.Server.Handlers.Simulation | |||
121 | 116 | ||
122 | } | 117 | } |
123 | 118 | ||
124 | protected void DoAgentPut(Hashtable request, Hashtable responsedata) | ||
125 | { | ||
126 | OSDMap args = Utils.GetOSDMap((string)request["body"]); | ||
127 | if (args == null) | ||
128 | { | ||
129 | responsedata["int_response_code"] = HttpStatusCode.BadRequest; | ||
130 | responsedata["str_response_string"] = "Bad request"; | ||
131 | return; | ||
132 | } | ||
133 | |||
134 | // retrieve the input arguments | ||
135 | int x = 0, y = 0; | ||
136 | UUID uuid = UUID.Zero; | ||
137 | string regionname = string.Empty; | ||
138 | if (args.ContainsKey("destination_x") && args["destination_x"] != null) | ||
139 | Int32.TryParse(args["destination_x"].AsString(), out x); | ||
140 | if (args.ContainsKey("destination_y") && args["destination_y"] != null) | ||
141 | Int32.TryParse(args["destination_y"].AsString(), out y); | ||
142 | if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) | ||
143 | UUID.TryParse(args["destination_uuid"].AsString(), out uuid); | ||
144 | if (args.ContainsKey("destination_name") && args["destination_name"] != null) | ||
145 | regionname = args["destination_name"].ToString(); | ||
146 | |||
147 | GridRegion destination = new GridRegion(); | ||
148 | destination.RegionID = uuid; | ||
149 | destination.RegionLocX = x; | ||
150 | destination.RegionLocY = y; | ||
151 | destination.RegionName = regionname; | ||
152 | |||
153 | string messageType; | ||
154 | if (args["message_type"] != null) | ||
155 | messageType = args["message_type"].AsString(); | ||
156 | else | ||
157 | { | ||
158 | m_log.Warn("[AGENT HANDLER]: Agent Put Message Type not found. "); | ||
159 | messageType = "AgentData"; | ||
160 | } | ||
161 | |||
162 | bool result = true; | ||
163 | if ("AgentData".Equals(messageType)) | ||
164 | { | ||
165 | AgentData agent = new AgentData(); | ||
166 | try | ||
167 | { | ||
168 | agent.Unpack(args, m_SimulationService.GetScene(destination.RegionHandle)); | ||
169 | } | ||
170 | catch (Exception ex) | ||
171 | { | ||
172 | m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); | ||
173 | responsedata["int_response_code"] = HttpStatusCode.BadRequest; | ||
174 | responsedata["str_response_string"] = "Bad request"; | ||
175 | return; | ||
176 | } | ||
177 | |||
178 | //agent.Dump(); | ||
179 | // This is one of the meanings of PUT agent | ||
180 | result = UpdateAgent(destination, agent); | ||
181 | |||
182 | } | ||
183 | else if ("AgentPosition".Equals(messageType)) | ||
184 | { | ||
185 | AgentPosition agent = new AgentPosition(); | ||
186 | try | ||
187 | { | ||
188 | agent.Unpack(args, m_SimulationService.GetScene(destination.RegionHandle)); | ||
189 | } | ||
190 | catch (Exception ex) | ||
191 | { | ||
192 | m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); | ||
193 | return; | ||
194 | } | ||
195 | //agent.Dump(); | ||
196 | // This is one of the meanings of PUT agent | ||
197 | result = m_SimulationService.UpdateAgent(destination, agent); | ||
198 | |||
199 | } | ||
200 | |||
201 | responsedata["int_response_code"] = HttpStatusCode.OK; | ||
202 | responsedata["str_response_string"] = result.ToString(); | ||
203 | //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead | ||
204 | } | ||
205 | |||
206 | // subclasses can override this | ||
207 | protected virtual bool UpdateAgent(GridRegion destination, AgentData agent) | ||
208 | { | ||
209 | return m_SimulationService.UpdateAgent(destination, agent); | ||
210 | } | ||
211 | |||
212 | protected virtual void DoQueryAccess(Hashtable request, Hashtable responsedata, UUID id, UUID regionID) | 119 | protected virtual void DoQueryAccess(Hashtable request, Hashtable responsedata, UUID id, UUID regionID) |
213 | { | 120 | { |
214 | if (m_SimulationService == null) | 121 | if (m_SimulationService == null) |
@@ -508,4 +415,173 @@ namespace OpenSim.Server.Handlers.Simulation | |||
508 | return m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); | 415 | return m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); |
509 | } | 416 | } |
510 | } | 417 | } |
418 | |||
419 | public class AgentPutHandler : BaseStreamHandler | ||
420 | { | ||
421 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
422 | |||
423 | private ISimulationService m_SimulationService; | ||
424 | protected bool m_Proxy = false; | ||
425 | |||
426 | public AgentPutHandler(ISimulationService service) : | ||
427 | base("PUT", "/agent") | ||
428 | { | ||
429 | m_SimulationService = service; | ||
430 | } | ||
431 | |||
432 | public AgentPutHandler(string path) : | ||
433 | base("PUT", path) | ||
434 | { | ||
435 | m_SimulationService = null; | ||
436 | } | ||
437 | |||
438 | public override byte[] Handle(string path, Stream request, | ||
439 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
440 | { | ||
441 | m_log.DebugFormat("[SIMULATION]: Stream handler called"); | ||
442 | |||
443 | Hashtable keysvals = new Hashtable(); | ||
444 | Hashtable headervals = new Hashtable(); | ||
445 | |||
446 | string[] querystringkeys = httpRequest.QueryString.AllKeys; | ||
447 | string[] rHeaders = httpRequest.Headers.AllKeys; | ||
448 | |||
449 | keysvals.Add("uri", httpRequest.RawUrl); | ||
450 | keysvals.Add("content-type", httpRequest.ContentType); | ||
451 | keysvals.Add("http-method", httpRequest.HttpMethod); | ||
452 | |||
453 | foreach (string queryname in querystringkeys) | ||
454 | keysvals.Add(queryname, httpRequest.QueryString[queryname]); | ||
455 | |||
456 | foreach (string headername in rHeaders) | ||
457 | headervals[headername] = httpRequest.Headers[headername]; | ||
458 | |||
459 | keysvals.Add("headers", headervals); | ||
460 | keysvals.Add("querystringkeys", querystringkeys); | ||
461 | |||
462 | Stream inputStream; | ||
463 | if (httpRequest.ContentType == "application/x-gzip") | ||
464 | inputStream = new GZipStream(request, CompressionMode.Decompress); | ||
465 | else | ||
466 | inputStream = request; | ||
467 | |||
468 | Encoding encoding = Encoding.UTF8; | ||
469 | StreamReader reader = new StreamReader(inputStream, encoding); | ||
470 | |||
471 | string requestBody = reader.ReadToEnd(); | ||
472 | keysvals.Add("body", requestBody); | ||
473 | |||
474 | httpResponse.StatusCode = 200; | ||
475 | httpResponse.ContentType = "text/html"; | ||
476 | httpResponse.KeepAlive = false; | ||
477 | |||
478 | Hashtable responsedata = new Hashtable(); | ||
479 | |||
480 | UUID agentID; | ||
481 | UUID regionID; | ||
482 | string action; | ||
483 | |||
484 | if (!Utils.GetParams((string)keysvals["uri"], out agentID, out regionID, out action)) | ||
485 | { | ||
486 | m_log.InfoFormat("[AGENT HANDLER]: Invalid parameters for agent message {0}", keysvals["uri"]); | ||
487 | |||
488 | httpResponse.StatusCode = 404; | ||
489 | |||
490 | return encoding.GetBytes("false"); | ||
491 | } | ||
492 | |||
493 | DoAgentPut(keysvals, responsedata); | ||
494 | |||
495 | httpResponse.StatusCode = (int)responsedata["int_response_code"]; | ||
496 | return encoding.GetBytes((string)responsedata["str_response_string"]); | ||
497 | } | ||
498 | |||
499 | protected void DoAgentPut(Hashtable request, Hashtable responsedata) | ||
500 | { | ||
501 | OSDMap args = Utils.GetOSDMap((string)request["body"]); | ||
502 | if (args == null) | ||
503 | { | ||
504 | responsedata["int_response_code"] = HttpStatusCode.BadRequest; | ||
505 | responsedata["str_response_string"] = "Bad request"; | ||
506 | return; | ||
507 | } | ||
508 | |||
509 | // retrieve the input arguments | ||
510 | int x = 0, y = 0; | ||
511 | UUID uuid = UUID.Zero; | ||
512 | string regionname = string.Empty; | ||
513 | if (args.ContainsKey("destination_x") && args["destination_x"] != null) | ||
514 | Int32.TryParse(args["destination_x"].AsString(), out x); | ||
515 | if (args.ContainsKey("destination_y") && args["destination_y"] != null) | ||
516 | Int32.TryParse(args["destination_y"].AsString(), out y); | ||
517 | if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) | ||
518 | UUID.TryParse(args["destination_uuid"].AsString(), out uuid); | ||
519 | if (args.ContainsKey("destination_name") && args["destination_name"] != null) | ||
520 | regionname = args["destination_name"].ToString(); | ||
521 | |||
522 | GridRegion destination = new GridRegion(); | ||
523 | destination.RegionID = uuid; | ||
524 | destination.RegionLocX = x; | ||
525 | destination.RegionLocY = y; | ||
526 | destination.RegionName = regionname; | ||
527 | |||
528 | string messageType; | ||
529 | if (args["message_type"] != null) | ||
530 | messageType = args["message_type"].AsString(); | ||
531 | else | ||
532 | { | ||
533 | m_log.Warn("[AGENT HANDLER]: Agent Put Message Type not found. "); | ||
534 | messageType = "AgentData"; | ||
535 | } | ||
536 | |||
537 | bool result = true; | ||
538 | if ("AgentData".Equals(messageType)) | ||
539 | { | ||
540 | AgentData agent = new AgentData(); | ||
541 | try | ||
542 | { | ||
543 | agent.Unpack(args, m_SimulationService.GetScene(destination.RegionHandle)); | ||
544 | } | ||
545 | catch (Exception ex) | ||
546 | { | ||
547 | m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); | ||
548 | responsedata["int_response_code"] = HttpStatusCode.BadRequest; | ||
549 | responsedata["str_response_string"] = "Bad request"; | ||
550 | return; | ||
551 | } | ||
552 | |||
553 | //agent.Dump(); | ||
554 | // This is one of the meanings of PUT agent | ||
555 | result = UpdateAgent(destination, agent); | ||
556 | |||
557 | } | ||
558 | else if ("AgentPosition".Equals(messageType)) | ||
559 | { | ||
560 | AgentPosition agent = new AgentPosition(); | ||
561 | try | ||
562 | { | ||
563 | agent.Unpack(args, m_SimulationService.GetScene(destination.RegionHandle)); | ||
564 | } | ||
565 | catch (Exception ex) | ||
566 | { | ||
567 | m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); | ||
568 | return; | ||
569 | } | ||
570 | //agent.Dump(); | ||
571 | // This is one of the meanings of PUT agent | ||
572 | result = m_SimulationService.UpdateAgent(destination, agent); | ||
573 | |||
574 | } | ||
575 | |||
576 | responsedata["int_response_code"] = HttpStatusCode.OK; | ||
577 | responsedata["str_response_string"] = result.ToString(); | ||
578 | //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead | ||
579 | } | ||
580 | |||
581 | // subclasses can override this | ||
582 | protected virtual bool UpdateAgent(GridRegion destination, AgentData agent) | ||
583 | { | ||
584 | return m_SimulationService.UpdateAgent(destination, agent); | ||
585 | } | ||
586 | } | ||
511 | } | 587 | } |
diff --git a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs index 42d8eca..0da08f8 100644 --- a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs +++ b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs | |||
@@ -50,6 +50,7 @@ namespace OpenSim.Server.Handlers.Simulation | |||
50 | // are pure binary and shoehorning that into a string with UTF-8 | 50 | // are pure binary and shoehorning that into a string with UTF-8 |
51 | // encoding breaks it | 51 | // encoding breaks it |
52 | server.AddStreamHandler(new AgentPostHandler(m_LocalSimulationService)); | 52 | server.AddStreamHandler(new AgentPostHandler(m_LocalSimulationService)); |
53 | server.AddStreamHandler(new AgentPutHandler(m_LocalSimulationService)); | ||
53 | server.AddHTTPHandler("/agent/", new AgentHandler(m_LocalSimulationService).Handler); | 54 | server.AddHTTPHandler("/agent/", new AgentHandler(m_LocalSimulationService).Handler); |
54 | server.AddHTTPHandler("/object/", new ObjectHandler(m_LocalSimulationService).Handler); | 55 | server.AddHTTPHandler("/object/", new ObjectHandler(m_LocalSimulationService).Handler); |
55 | } | 56 | } |