aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Communications
diff options
context:
space:
mode:
authordiva2009-02-09 22:27:27 +0000
committerdiva2009-02-09 22:27:27 +0000
commit2c685bff1493451849580cfb6bf44b88322bf0a4 (patch)
tree4179700c2b1fcbcc7a5ab07f7bc65b3bf97a79d9 /OpenSim/Region/Environment/Modules/Communications
parentThank you kindly, TLaukkan (Timmil) for a patch that: (diff)
downloadopensim-SC-2c685bff1493451849580cfb6bf44b88322bf0a4.zip
opensim-SC-2c685bff1493451849580cfb6bf44b88322bf0a4.tar.gz
opensim-SC-2c685bff1493451849580cfb6bf44b88322bf0a4.tar.bz2
opensim-SC-2c685bff1493451849580cfb6bf44b88322bf0a4.tar.xz
Moved prim crossing out of OGS1 and into RESTComms and LocalInterregionComms. This breaks interregion comms with older versions in what concerns prim crossing. In the process of moving the comms, a few things seem to be working better, namely this may address mantis #3011, mantis #1698. Hopefully, this doesn't break anything else. But I'm still seeing weirdnesses with attchments jumping out of place after a cross/TP.
The two most notable changes in the crossing process were: * Object gets passed in only one message, not two as done before. * Local object crossings do not get serialized, as done before.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Communications')
-rw-r--r--OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs35
-rw-r--r--OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs244
2 files changed, 270 insertions, 9 deletions
diff --git a/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs b/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs
index cb60d3f..33ccbf4 100644
--- a/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs
+++ b/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs
@@ -116,6 +116,10 @@ namespace OpenSim.Region.Environment.Modules.Communications.Local
116 116
117 #region IInterregionComms 117 #region IInterregionComms
118 118
119 /**
120 * Agent-related communications
121 */
122
119 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit) 123 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit)
120 { 124 {
121 foreach (Scene s in m_sceneList) 125 foreach (Scene s in m_sceneList)
@@ -204,6 +208,37 @@ namespace OpenSim.Region.Environment.Modules.Communications.Local
204 return false; 208 return false;
205 } 209 }
206 210
211 /**
212 * Object-related communications
213 */
214
215 public bool SendCreateObject(ulong regionHandle, ISceneObject sog)
216 {
217 foreach (Scene s in m_sceneList)
218 {
219 if (s.RegionInfo.RegionHandle == regionHandle)
220 {
221 //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject");
222 return s.IncomingCreateObject(sog);
223 }
224 }
225 return false;
226 }
227
207 #endregion /* IInterregionComms */ 228 #endregion /* IInterregionComms */
229
230 #region Misc
231
232 public UUID GetRegionID(ulong regionhandle)
233 {
234 foreach (Scene s in m_sceneList)
235 {
236 if (s.RegionInfo.RegionHandle == regionhandle)
237 return s.RegionInfo.RegionID;
238 }
239 // ? weird. should not happen
240 return m_sceneList[0].RegionInfo.RegionID;
241 }
242 #endregion
208 } 243 }
209} 244}
diff --git a/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs b/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs
index cfcd618..95b95ee 100644
--- a/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs
+++ b/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs
@@ -123,12 +123,17 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
123 protected virtual void AddHTTPHandlers() 123 protected virtual void AddHTTPHandlers()
124 { 124 {
125 m_aScene.CommsManager.HttpServer.AddHTTPHandler("/agent/", AgentHandler); 125 m_aScene.CommsManager.HttpServer.AddHTTPHandler("/agent/", AgentHandler);
126 m_aScene.CommsManager.HttpServer.AddHTTPHandler("/object/", ObjectHandler);
126 } 127 }
127 128
128 #endregion /* IRegionModule */ 129 #endregion /* IRegionModule */
129 130
130 #region IInterregionComms 131 #region IInterregionComms
131 132
133 /**
134 * Agent-related communications
135 */
136
132 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit) 137 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit)
133 { 138 {
134 // Try local first 139 // Try local first
@@ -209,7 +214,32 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
209 //else 214 //else
210 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); 215 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
211 return false; 216 return false;
212 } 217 }
218
219 /**
220 * Object-related communications
221 */
222
223 public bool SendCreateObject(ulong regionHandle, ISceneObject sog)
224 {
225 // Try local first
226 ISceneObject sogClone = sog.CloneForNewScene();
227 if (m_localBackend.SendCreateObject(regionHandle, sogClone))
228 {
229 //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded");
230 return true;
231 }
232
233 // else do the remote thing
234 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle);
235 if (regInfo != null)
236 {
237 return DoCreateObjectCall(regInfo, sog);
238 }
239 //else
240 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
241 return false;
242 }
213 243
214 #endregion /* IInterregionComms */ 244 #endregion /* IInterregionComms */
215 245
@@ -454,10 +484,95 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
454 return true; 484 return true;
455 } 485 }
456 486
487 protected bool DoCreateObjectCall(RegionInfo region, ISceneObject sog)
488 {
489 ulong regionHandle = GetRegionHandle(region.RegionHandle);
490 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/";
491 //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri);
492
493 WebRequest ObjectCreateRequest = WebRequest.Create(uri);
494 ObjectCreateRequest.Method = "POST";
495 ObjectCreateRequest.ContentType = "text/xml";
496 ObjectCreateRequest.Timeout = 10000;
497
498 OSDMap args = new OSDMap(2);
499 args["sog"] = OSD.FromString(sog.ToXmlString2());
500 args["extra"] = OSD.FromString(sog.ExtraToXmlString());
501 if (m_aScene.m_allowScriptCrossings)
502 {
503 string state = sog.GetStateSnapshot();
504 if (state.Length > 0)
505 args["state"] = OSD.FromString(state);
506 }
507
508 string strBuffer = "";
509 byte[] buffer = new byte[1];
510 try
511 {
512 strBuffer = OSDParser.SerializeJsonString(args);
513 System.Text.UTF8Encoding str = new System.Text.UTF8Encoding();
514 buffer = str.GetBytes(strBuffer);
515
516 }
517 catch (Exception e)
518 {
519 m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message);
520 // ignore. buffer will be empty, caller should check.
521 }
522
523 Stream os = null;
524 try
525 { // send the Post
526 ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send
527 os = ObjectCreateRequest.GetRequestStream();
528 os.Write(buffer, 0, strBuffer.Length); //Send it
529 os.Close();
530 m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri);
531 }
532 //catch (WebException ex)
533 catch
534 {
535 // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message);
536
537 return false;
538 }
539
540 // Let's wait for the response
541 //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall");
542
543 try
544 {
545 WebResponse webResponse = ObjectCreateRequest.GetResponse();
546 if (webResponse == null)
547 {
548 m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post");
549 }
550
551 StreamReader sr = new StreamReader(webResponse.GetResponseStream());
552 //reply = sr.ReadToEnd().Trim();
553 sr.ReadToEnd().Trim();
554 sr.Close();
555 //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply);
556
557 }
558 catch (WebException ex)
559 {
560 m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message);
561 // ignore, really
562 }
563
564 return true;
565
566 }
567
457 #endregion /* Do Work */ 568 #endregion /* Do Work */
458 569
459 #region Incoming calls from remote instances 570 #region Incoming calls from remote instances
460 571
572 /**
573 * Agent-related incoming calls
574 */
575
461 public Hashtable AgentHandler(Hashtable request) 576 public Hashtable AgentHandler(Hashtable request)
462 { 577 {
463 //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); 578 //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called");
@@ -487,17 +602,17 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
487 string method = (string)request["http-method"]; 602 string method = (string)request["http-method"];
488 if (method.Equals("PUT")) 603 if (method.Equals("PUT"))
489 { 604 {
490 DoPut(request, responsedata); 605 DoAgentPut(request, responsedata);
491 return responsedata; 606 return responsedata;
492 } 607 }
493 else if (method.Equals("POST")) 608 else if (method.Equals("POST"))
494 { 609 {
495 DoPost(request, responsedata, agentID); 610 DoAgentPost(request, responsedata, agentID);
496 return responsedata; 611 return responsedata;
497 } 612 }
498 else if (method.Equals("DELETE")) 613 else if (method.Equals("DELETE"))
499 { 614 {
500 DoDelete(request, responsedata, agentID, action, regionHandle); 615 DoAgentDelete(request, responsedata, agentID, action, regionHandle);
501 616
502 return responsedata; 617 return responsedata;
503 } 618 }
@@ -534,12 +649,12 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
534 } 649 }
535 catch (Exception ex) 650 catch (Exception ex)
536 { 651 {
537 m_log.InfoFormat("[REST COMMS]: exception on parse of ChildAgentUpdate message {0}", ex.Message); 652 m_log.InfoFormat("[REST COMMS]: exception on parse of REST message {0}", ex.Message);
538 return null; 653 return null;
539 } 654 }
540 } 655 }
541 656
542 protected virtual void DoPost(Hashtable request, Hashtable responsedata, UUID id) 657 protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
543 { 658 {
544 OSDMap args = GetOSDMap(request); 659 OSDMap args = GetOSDMap(request);
545 if (args == null) 660 if (args == null)
@@ -573,7 +688,7 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
573 responsedata["str_response_string"] = result.ToString(); 688 responsedata["str_response_string"] = result.ToString();
574 } 689 }
575 690
576 protected virtual void DoPut(Hashtable request, Hashtable responsedata) 691 protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata)
577 { 692 {
578 OSDMap args = GetOSDMap(request); 693 OSDMap args = GetOSDMap(request);
579 if (args == null) 694 if (args == null)
@@ -639,7 +754,7 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
639 responsedata["str_response_string"] = result.ToString(); 754 responsedata["str_response_string"] = result.ToString();
640 } 755 }
641 756
642 protected virtual void DoDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle) 757 protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle)
643 { 758 {
644 //Console.WriteLine(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle); 759 //Console.WriteLine(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle);
645 760
@@ -651,7 +766,118 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
651 responsedata["int_response_code"] = 200; 766 responsedata["int_response_code"] = 200;
652 responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); 767 responsedata["str_response_string"] = "OpenSim agent " + id.ToString();
653 } 768 }
654 769
770 /**
771 * Object-related incoming calls
772 */
773
774 public Hashtable ObjectHandler(Hashtable request)
775 {
776 //m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called");
777
778 //Console.WriteLine("---------------------------");
779 //Console.WriteLine(" >> uri=" + request["uri"]);
780 //Console.WriteLine(" >> content-type=" + request["content-type"]);
781 //Console.WriteLine(" >> http-method=" + request["http-method"]);
782 //Console.WriteLine("---------------------------\n");
783
784 Hashtable responsedata = new Hashtable();
785 responsedata["content_type"] = "text/html";
786
787 UUID objectID;
788 string action;
789 ulong regionHandle;
790 if (!GetParams((string)request["uri"], out objectID, out regionHandle, out action))
791 {
792 m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]);
793 responsedata["int_response_code"] = 404;
794 responsedata["str_response_string"] = "false";
795
796 return responsedata;
797 }
798
799 // Next, let's parse the verb
800 string method = (string)request["http-method"];
801 if (method.Equals("POST"))
802 {
803 DoObjectPost(request, responsedata, regionHandle);
804 return responsedata;
805 }
806 //else if (method.Equals("PUT"))
807 //{
808 // DoObjectPut(request, responsedata, agentID);
809 // return responsedata;
810 //}
811 //else if (method.Equals("DELETE"))
812 //{
813 // DoObjectDelete(request, responsedata, agentID, action, regionHandle);
814 // return responsedata;
815 //}
816 else
817 {
818 m_log.InfoFormat("[REST COMMS]: method {0} not supported in object message", method);
819 responsedata["int_response_code"] = 404;
820 responsedata["str_response_string"] = "false";
821
822 return responsedata;
823 }
824
825 }
826
827 protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle)
828 {
829 OSDMap args = GetOSDMap(request);
830 if (args == null)
831 {
832 responsedata["int_response_code"] = 400;
833 responsedata["str_response_string"] = "false";
834 return;
835 }
836
837 string sogXmlStr = "", extraStr = "", stateXmlStr = "";
838 if (args["sog"] != null)
839 sogXmlStr = args["sog"].AsString();
840 if (args["extra"] != null)
841 extraStr = args["extra"].AsString();
842
843 UUID regionID = m_localBackend.GetRegionID(regionhandle);
844 SceneObjectGroup sog = null;
845 try
846 {
847 sog = new SceneObjectGroup(sogXmlStr);
848 sog.ExtraFromXmlString(extraStr);
849 }
850 catch (Exception ex)
851 {
852 m_log.InfoFormat("[REST COMMS]: exception on deserializing scene object {0}", ex.Message);
853 responsedata["int_response_code"] = 400;
854 responsedata["str_response_string"] = "false";
855 return;
856 }
857
858 if ((args["state"] != null) && m_aScene.m_allowScriptCrossings)
859 {
860 stateXmlStr = args["state"].AsString();
861 if (stateXmlStr != "")
862 {
863 try
864 {
865 sog.SetState(stateXmlStr, regionID);
866 }
867 catch (Exception ex)
868 {
869 m_log.InfoFormat("[REST COMMS]: exception on setting state for scene object {0}", ex.Message);
870
871 }
872 }
873 }
874 // This is the meaning of POST object
875 bool result = m_localBackend.SendCreateObject(regionhandle, sog);
876
877 responsedata["int_response_code"] = 200;
878 responsedata["str_response_string"] = result.ToString();
879 }
880
655 #endregion 881 #endregion
656 882
657 #region Misc 883 #region Misc