diff options
author | diva | 2009-03-23 02:37:19 +0000 |
---|---|---|
committer | diva | 2009-03-23 02:37:19 +0000 |
commit | 5af63a6a5c98fb153a07dcaac067ec3b94d6bdee (patch) | |
tree | 85ba6a5faadac0ba23a18b6572c478ba13462238 /OpenSim/Region | |
parent | Finish folder gives. With this commit, single item and folder gives now (diff) | |
download | opensim-SC_OLD-5af63a6a5c98fb153a07dcaac067ec3b94d6bdee.zip opensim-SC_OLD-5af63a6a5c98fb153a07dcaac067ec3b94d6bdee.tar.gz opensim-SC_OLD-5af63a6a5c98fb153a07dcaac067ec3b94d6bdee.tar.bz2 opensim-SC_OLD-5af63a6a5c98fb153a07dcaac067ec3b94d6bdee.tar.xz |
Root agent retrieval via http/REST. This is a pull, the caller gets the agent. This is not used by the regions yet, but it may be a better alternative to transfer agents even when that is done by the regions. The data is still trivial; soon it will have attachments, scripts and script state. Also, authorization tokens still to come. Serialization using OSD/json, as the other methods.
Diffstat (limited to 'OpenSim/Region')
6 files changed, 209 insertions, 35 deletions
diff --git a/OpenSim/Region/CoreModules/Communications/Local/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/Communications/Local/LocalInterregionComms.cs index 3997258..fb293e8 100644 --- a/OpenSim/Region/CoreModules/Communications/Local/LocalInterregionComms.cs +++ b/OpenSim/Region/CoreModules/Communications/Local/LocalInterregionComms.cs | |||
@@ -162,6 +162,21 @@ namespace OpenSim.Region.CoreModules.Communications.Local | |||
162 | return false; | 162 | return false; |
163 | } | 163 | } |
164 | 164 | ||
165 | public bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent) | ||
166 | { | ||
167 | agent = null; | ||
168 | foreach (Scene s in m_sceneList) | ||
169 | { | ||
170 | if (s.RegionInfo.RegionHandle == regionHandle) | ||
171 | { | ||
172 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | ||
173 | return s.IncomingRetrieveRootAgent(id, out agent); | ||
174 | } | ||
175 | } | ||
176 | //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); | ||
177 | return false; | ||
178 | } | ||
179 | |||
165 | public bool SendReleaseAgent(ulong regionHandle, UUID id, string uri) | 180 | public bool SendReleaseAgent(ulong regionHandle, UUID id, string uri) |
166 | { | 181 | { |
167 | //uint x, y; | 182 | //uint x, y; |
diff --git a/OpenSim/Region/CoreModules/Communications/REST/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/Communications/REST/RESTInterregionComms.cs index 498ffd5..7d6a988 100644 --- a/OpenSim/Region/CoreModules/Communications/REST/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/Communications/REST/RESTInterregionComms.cs | |||
@@ -192,7 +192,28 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
192 | return false; | 192 | return false; |
193 | 193 | ||
194 | } | 194 | } |
195 | 195 | ||
196 | public bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent) | ||
197 | { | ||
198 | // Try local first | ||
199 | if (m_localBackend.SendRetrieveRootAgent(regionHandle, id, out agent)) | ||
200 | return true; | ||
201 | |||
202 | // else do the remote thing | ||
203 | if (!m_localBackend.IsLocalRegion(regionHandle)) | ||
204 | { | ||
205 | RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); | ||
206 | if (regInfo != null) | ||
207 | { | ||
208 | return DoRetrieveRootAgentCall(regInfo, id, out agent); | ||
209 | } | ||
210 | //else | ||
211 | // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); | ||
212 | } | ||
213 | return false; | ||
214 | |||
215 | } | ||
216 | |||
196 | public bool SendReleaseAgent(ulong regionHandle, UUID id, string uri) | 217 | public bool SendReleaseAgent(ulong regionHandle, UUID id, string uri) |
197 | { | 218 | { |
198 | // Try local first | 219 | // Try local first |
@@ -203,6 +224,7 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
203 | return DoReleaseAgentCall(regionHandle, id, uri); | 224 | return DoReleaseAgentCall(regionHandle, id, uri); |
204 | } | 225 | } |
205 | 226 | ||
227 | |||
206 | public bool SendCloseAgent(ulong regionHandle, UUID id) | 228 | public bool SendCloseAgent(ulong regionHandle, UUID id) |
207 | { | 229 | { |
208 | // Try local first | 230 | // Try local first |
@@ -288,12 +310,13 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
288 | { | 310 | { |
289 | // Eventually, we want to use a caps url instead of the agentID | 311 | // Eventually, we want to use a caps url instead of the agentID |
290 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; | 312 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; |
291 | //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); | 313 | //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); |
292 | 314 | ||
293 | WebRequest AgentCreateRequest = WebRequest.Create(uri); | 315 | HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); |
294 | AgentCreateRequest.Method = "POST"; | 316 | AgentCreateRequest.Method = "POST"; |
295 | AgentCreateRequest.ContentType = "application/json"; | 317 | AgentCreateRequest.ContentType = "application/json"; |
296 | AgentCreateRequest.Timeout = 10000; | 318 | AgentCreateRequest.Timeout = 10000; |
319 | //AgentCreateRequest.KeepAlive = false; | ||
297 | 320 | ||
298 | // Fill it in | 321 | // Fill it in |
299 | OSDMap args = null; | 322 | OSDMap args = null; |
@@ -373,18 +396,19 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
373 | { | 396 | { |
374 | // Eventually, we want to use a caps url instead of the agentID | 397 | // Eventually, we want to use a caps url instead of the agentID |
375 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; | 398 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; |
376 | //m_log.Debug(" >>> DoChildAgentUpdateCall <<< " + uri); | 399 | //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); |
377 | 400 | ||
378 | WebRequest ChildUpdateRequest = WebRequest.Create(uri); | 401 | HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); |
379 | ChildUpdateRequest.Method = "PUT"; | 402 | ChildUpdateRequest.Method = "PUT"; |
380 | ChildUpdateRequest.ContentType = "application/json"; | 403 | ChildUpdateRequest.ContentType = "application/json"; |
381 | ChildUpdateRequest.Timeout = 10000; | 404 | ChildUpdateRequest.Timeout = 10000; |
405 | //ChildUpdateRequest.KeepAlive = false; | ||
382 | 406 | ||
383 | // Fill it in | 407 | // Fill it in |
384 | OSDMap args = null; | 408 | OSDMap args = null; |
385 | try | 409 | try |
386 | { | 410 | { |
387 | args = cAgentData.PackUpdateMessage(); | 411 | args = cAgentData.Pack(); |
388 | } | 412 | } |
389 | catch (Exception e) | 413 | catch (Exception e) |
390 | { | 414 | { |
@@ -453,6 +477,61 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
453 | return true; | 477 | return true; |
454 | } | 478 | } |
455 | 479 | ||
480 | public bool DoRetrieveRootAgentCall(RegionInfo region, UUID id, out IAgentData agent) | ||
481 | { | ||
482 | agent = null; | ||
483 | // Eventually, we want to use a caps url instead of the agentID | ||
484 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; | ||
485 | //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); | ||
486 | |||
487 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); | ||
488 | request.Method = "GET"; | ||
489 | request.Timeout = 10000; | ||
490 | //request.Headers.Add("authorization", ""); // coming soon | ||
491 | |||
492 | HttpWebResponse webResponse = null; | ||
493 | string reply = string.Empty; | ||
494 | try | ||
495 | { | ||
496 | webResponse = (HttpWebResponse)request.GetResponse(); | ||
497 | if (webResponse == null) | ||
498 | { | ||
499 | m_log.Info("[REST COMMS]: Null reply on agent get "); | ||
500 | } | ||
501 | |||
502 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | ||
503 | reply = sr.ReadToEnd().Trim(); | ||
504 | sr.Close(); | ||
505 | |||
506 | //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); | ||
507 | |||
508 | } | ||
509 | catch (WebException ex) | ||
510 | { | ||
511 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); | ||
512 | // ignore, really | ||
513 | return false; | ||
514 | } | ||
515 | |||
516 | if (webResponse.StatusCode == HttpStatusCode.OK) | ||
517 | { | ||
518 | // we know it's jason | ||
519 | OSDMap args = GetOSDMap(reply); | ||
520 | if (args == null) | ||
521 | { | ||
522 | //Console.WriteLine("[REST COMMS]: Error getting OSDMap from reply"); | ||
523 | return false; | ||
524 | } | ||
525 | |||
526 | agent = new CompleteAgentData(); | ||
527 | agent.Unpack(args); | ||
528 | return true; | ||
529 | } | ||
530 | |||
531 | //Console.WriteLine("[REST COMMS]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); | ||
532 | return false; | ||
533 | } | ||
534 | |||
456 | public bool DoReleaseAgentCall(ulong regionHandle, UUID id, string uri) | 535 | public bool DoReleaseAgentCall(ulong regionHandle, UUID id, string uri) |
457 | { | 536 | { |
458 | //m_log.Debug(" >>> DoReleaseAgentCall <<< " + uri); | 537 | //m_log.Debug(" >>> DoReleaseAgentCall <<< " + uri); |
@@ -466,7 +545,7 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
466 | WebResponse webResponse = request.GetResponse(); | 545 | WebResponse webResponse = request.GetResponse(); |
467 | if (webResponse == null) | 546 | if (webResponse == null) |
468 | { | 547 | { |
469 | m_log.Info("[REST COMMS]: Null reply on agent get "); | 548 | m_log.Info("[REST COMMS]: Null reply on agent delete "); |
470 | } | 549 | } |
471 | 550 | ||
472 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 551 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); |
@@ -478,18 +557,19 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
478 | } | 557 | } |
479 | catch (WebException ex) | 558 | catch (WebException ex) |
480 | { | 559 | { |
481 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); | 560 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); |
482 | // ignore, really | 561 | // ignore, really |
483 | } | 562 | } |
484 | 563 | ||
485 | return true; | 564 | return true; |
486 | } | 565 | } |
487 | 566 | ||
567 | |||
488 | public bool DoCloseAgentCall(RegionInfo region, UUID id) | 568 | public bool DoCloseAgentCall(RegionInfo region, UUID id) |
489 | { | 569 | { |
490 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() +"/"; | 570 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() +"/"; |
491 | 571 | ||
492 | //m_log.Debug(" >>> DoCloseAgentCall <<< " + uri); | 572 | //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); |
493 | 573 | ||
494 | WebRequest request = WebRequest.Create(uri); | 574 | WebRequest request = WebRequest.Create(uri); |
495 | request.Method = "DELETE"; | 575 | request.Method = "DELETE"; |
@@ -500,7 +580,7 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
500 | WebResponse webResponse = request.GetResponse(); | 580 | WebResponse webResponse = request.GetResponse(); |
501 | if (webResponse == null) | 581 | if (webResponse == null) |
502 | { | 582 | { |
503 | m_log.Info("[REST COMMS]: Null reply on agent get "); | 583 | m_log.Info("[REST COMMS]: Null reply on agent delete "); |
504 | } | 584 | } |
505 | 585 | ||
506 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 586 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); |
@@ -512,7 +592,7 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
512 | } | 592 | } |
513 | catch (WebException ex) | 593 | catch (WebException ex) |
514 | { | 594 | { |
515 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); | 595 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); |
516 | // ignore, really | 596 | // ignore, really |
517 | } | 597 | } |
518 | 598 | ||
@@ -696,14 +776,15 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
696 | { | 776 | { |
697 | //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); | 777 | //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); |
698 | 778 | ||
699 | //m_log.Debug("---------------------------"); | 779 | m_log.Debug("---------------------------"); |
700 | //m_log.Debug(" >> uri=" + request["uri"]); | 780 | m_log.Debug(" >> uri=" + request["uri"]); |
701 | //m_log.Debug(" >> content-type=" + request["content-type"]); | 781 | m_log.Debug(" >> content-type=" + request["content-type"]); |
702 | //m_log.Debug(" >> http-method=" + request["http-method"]); | 782 | m_log.Debug(" >> http-method=" + request["http-method"]); |
703 | //m_log.Debug("---------------------------\n"); | 783 | m_log.Debug("---------------------------\n"); |
704 | 784 | ||
705 | Hashtable responsedata = new Hashtable(); | 785 | Hashtable responsedata = new Hashtable(); |
706 | responsedata["content_type"] = "text/html"; | 786 | responsedata["content_type"] = "text/html"; |
787 | responsedata["keepalive"] = false; | ||
707 | 788 | ||
708 | UUID agentID; | 789 | UUID agentID; |
709 | string action; | 790 | string action; |
@@ -729,10 +810,14 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
729 | DoAgentPost(request, responsedata, agentID); | 810 | DoAgentPost(request, responsedata, agentID); |
730 | return responsedata; | 811 | return responsedata; |
731 | } | 812 | } |
813 | else if (method.Equals("GET")) | ||
814 | { | ||
815 | DoAgentGet(request, responsedata, agentID, regionHandle); | ||
816 | return responsedata; | ||
817 | } | ||
732 | else if (method.Equals("DELETE")) | 818 | else if (method.Equals("DELETE")) |
733 | { | 819 | { |
734 | DoAgentDelete(request, responsedata, agentID, action, regionHandle); | 820 | DoAgentDelete(request, responsedata, agentID, action, regionHandle); |
735 | |||
736 | return responsedata; | 821 | return responsedata; |
737 | } | 822 | } |
738 | else | 823 | else |
@@ -748,7 +833,7 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
748 | 833 | ||
749 | protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) | 834 | protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) |
750 | { | 835 | { |
751 | OSDMap args = GetOSDMap(request); | 836 | OSDMap args = GetOSDMap((string)request["body"]); |
752 | if (args == null) | 837 | if (args == null) |
753 | { | 838 | { |
754 | responsedata["int_response_code"] = 400; | 839 | responsedata["int_response_code"] = 400; |
@@ -782,7 +867,7 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
782 | 867 | ||
783 | protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata) | 868 | protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata) |
784 | { | 869 | { |
785 | OSDMap args = GetOSDMap(request); | 870 | OSDMap args = GetOSDMap((string)request["body"]); |
786 | if (args == null) | 871 | if (args == null) |
787 | { | 872 | { |
788 | responsedata["int_response_code"] = 400; | 873 | responsedata["int_response_code"] = 400; |
@@ -810,13 +895,14 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
810 | AgentData agent = new AgentData(); | 895 | AgentData agent = new AgentData(); |
811 | try | 896 | try |
812 | { | 897 | { |
813 | agent.UnpackUpdateMessage(args); | 898 | agent.Unpack(args); |
814 | } | 899 | } |
815 | catch (Exception ex) | 900 | catch (Exception ex) |
816 | { | 901 | { |
817 | m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); | 902 | m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); |
818 | return; | 903 | return; |
819 | } | 904 | } |
905 | |||
820 | //agent.Dump(); | 906 | //agent.Dump(); |
821 | // This is one of the meanings of PUT agent | 907 | // This is one of the meanings of PUT agent |
822 | result = m_localBackend.SendChildAgentUpdate(regionhandle, agent); | 908 | result = m_localBackend.SendChildAgentUpdate(regionhandle, agent); |
@@ -827,7 +913,7 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
827 | AgentPosition agent = new AgentPosition(); | 913 | AgentPosition agent = new AgentPosition(); |
828 | try | 914 | try |
829 | { | 915 | { |
830 | agent.UnpackUpdateMessage(args); | 916 | agent.Unpack(args); |
831 | } | 917 | } |
832 | catch (Exception ex) | 918 | catch (Exception ex) |
833 | { | 919 | { |
@@ -840,12 +926,48 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
840 | 926 | ||
841 | } | 927 | } |
842 | 928 | ||
843 | |||
844 | |||
845 | responsedata["int_response_code"] = 200; | 929 | responsedata["int_response_code"] = 200; |
846 | responsedata["str_response_string"] = result.ToString(); | 930 | responsedata["str_response_string"] = result.ToString(); |
847 | } | 931 | } |
848 | 932 | ||
933 | protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, ulong regionHandle) | ||
934 | { | ||
935 | IAgentData agent = null; | ||
936 | bool result = m_localBackend.SendRetrieveRootAgent(regionHandle, id, out agent); | ||
937 | OSDMap map = null; | ||
938 | if (result) | ||
939 | { | ||
940 | if (agent != null) // just to make sure | ||
941 | { | ||
942 | map = agent.Pack(); | ||
943 | string strBuffer = ""; | ||
944 | try | ||
945 | { | ||
946 | strBuffer = OSDParser.SerializeJsonString(map); | ||
947 | } | ||
948 | catch (Exception e) | ||
949 | { | ||
950 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); | ||
951 | // ignore. buffer will be empty, caller should check. | ||
952 | } | ||
953 | |||
954 | responsedata["content_type"] = "application/json"; | ||
955 | responsedata["int_response_code"] = 200; | ||
956 | responsedata["str_response_string"] = strBuffer; | ||
957 | } | ||
958 | else | ||
959 | { | ||
960 | responsedata["int_response_code"] = 500; | ||
961 | responsedata["str_response_string"] = "Internal error"; | ||
962 | } | ||
963 | } | ||
964 | else | ||
965 | { | ||
966 | responsedata["int_response_code"] = 404; | ||
967 | responsedata["str_response_string"] = "Not Found"; | ||
968 | } | ||
969 | } | ||
970 | |||
849 | protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle) | 971 | protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle) |
850 | { | 972 | { |
851 | //m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle); | 973 | //m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle); |
@@ -857,6 +979,8 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
857 | 979 | ||
858 | responsedata["int_response_code"] = 200; | 980 | responsedata["int_response_code"] = 200; |
859 | responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); | 981 | responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); |
982 | |||
983 | m_log.Debug("[REST COMMS]: Agent Deleted."); | ||
860 | } | 984 | } |
861 | 985 | ||
862 | /** | 986 | /** |
@@ -918,7 +1042,7 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
918 | 1042 | ||
919 | protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle) | 1043 | protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle) |
920 | { | 1044 | { |
921 | OSDMap args = GetOSDMap(request); | 1045 | OSDMap args = GetOSDMap((string)request["body"]); |
922 | if (args == null) | 1046 | if (args == null) |
923 | { | 1047 | { |
924 | responsedata["int_response_code"] = 400; | 1048 | responsedata["int_response_code"] = 400; |
@@ -1030,7 +1154,7 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
1030 | 1154 | ||
1031 | protected virtual void DoRegionPost(Hashtable request, Hashtable responsedata, UUID id) | 1155 | protected virtual void DoRegionPost(Hashtable request, Hashtable responsedata, UUID id) |
1032 | { | 1156 | { |
1033 | OSDMap args = GetOSDMap(request); | 1157 | OSDMap args = GetOSDMap((string)request["body"]); |
1034 | if (args == null) | 1158 | if (args == null) |
1035 | { | 1159 | { |
1036 | responsedata["int_response_code"] = 400; | 1160 | responsedata["int_response_code"] = 400; |
@@ -1066,14 +1190,14 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
1066 | 1190 | ||
1067 | #region Misc | 1191 | #region Misc |
1068 | 1192 | ||
1069 | public static OSDMap GetOSDMap(Hashtable request) | 1193 | public static OSDMap GetOSDMap(string data) |
1070 | { | 1194 | { |
1071 | OSDMap args = null; | 1195 | OSDMap args = null; |
1072 | try | 1196 | try |
1073 | { | 1197 | { |
1074 | OSD buffer; | 1198 | OSD buffer; |
1075 | // We should pay attention to the content-type, but let's assume we know it's Json | 1199 | // We should pay attention to the content-type, but let's assume we know it's Json |
1076 | buffer = OSDParser.DeserializeJson((string)request["body"]); | 1200 | buffer = OSDParser.DeserializeJson(data); |
1077 | if (buffer.Type == OSDType.Map) | 1201 | if (buffer.Type == OSDType.Map) |
1078 | { | 1202 | { |
1079 | args = (OSDMap)buffer; | 1203 | args = (OSDMap)buffer; |
@@ -1082,13 +1206,13 @@ namespace OpenSim.Region.CoreModules.Communications.REST | |||
1082 | else | 1206 | else |
1083 | { | 1207 | { |
1084 | // uh? | 1208 | // uh? |
1085 | m_log.Debug("[REST COMMS]: Got OSD of type " + buffer.Type.ToString()); | 1209 | Console.WriteLine("[REST COMMS]: Got OSD of type " + buffer.Type.ToString()); |
1086 | return null; | 1210 | return null; |
1087 | } | 1211 | } |
1088 | } | 1212 | } |
1089 | catch (Exception ex) | 1213 | catch (Exception ex) |
1090 | { | 1214 | { |
1091 | m_log.InfoFormat("[REST COMMS]: exception on parse of REST message {0}", ex.Message); | 1215 | Console.WriteLine("[REST COMMS]: exception on parse of REST message " + ex.Message); |
1092 | return null; | 1216 | return null; |
1093 | } | 1217 | } |
1094 | } | 1218 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs index 15268c1..ef3cb51 100644 --- a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs | |||
@@ -56,6 +56,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
56 | /// <returns></returns> | 56 | /// <returns></returns> |
57 | bool SendChildAgentUpdate(ulong regionHandle, AgentPosition data); | 57 | bool SendChildAgentUpdate(ulong regionHandle, AgentPosition data); |
58 | 58 | ||
59 | bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent); | ||
60 | |||
59 | /// <summary> | 61 | /// <summary> |
60 | /// Message from receiving region to departing region, telling it got contacted by the client. | 62 | /// Message from receiving region to departing region, telling it got contacted by the client. |
61 | /// When sent over REST, it invokes the opaque uri. | 63 | /// When sent over REST, it invokes the opaque uri. |
diff --git a/OpenSim/Region/Framework/Scenes/ChildAgentDataUpdate.cs b/OpenSim/Region/Framework/Scenes/ChildAgentDataUpdate.cs index 17d3bb9..7e6e52a 100644 --- a/OpenSim/Region/Framework/Scenes/ChildAgentDataUpdate.cs +++ b/OpenSim/Region/Framework/Scenes/ChildAgentDataUpdate.cs | |||
@@ -40,8 +40,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
40 | { | 40 | { |
41 | UUID AgentID { get; set; } | 41 | UUID AgentID { get; set; } |
42 | 42 | ||
43 | OSDMap PackUpdateMessage(); | 43 | OSDMap Pack(); |
44 | void UnpackUpdateMessage(OSDMap map); | 44 | void Unpack(OSDMap map); |
45 | } | 45 | } |
46 | 46 | ||
47 | /// <summary> | 47 | /// <summary> |
@@ -74,7 +74,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
74 | public byte[] Throttles; | 74 | public byte[] Throttles; |
75 | 75 | ||
76 | 76 | ||
77 | public OSDMap PackUpdateMessage() | 77 | public OSDMap Pack() |
78 | { | 78 | { |
79 | OSDMap args = new OSDMap(); | 79 | OSDMap args = new OSDMap(); |
80 | args["message_type"] = OSD.FromString("AgentPosition"); | 80 | args["message_type"] = OSD.FromString("AgentPosition"); |
@@ -101,7 +101,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
101 | return args; | 101 | return args; |
102 | } | 102 | } |
103 | 103 | ||
104 | public void UnpackUpdateMessage(OSDMap args) | 104 | public void Unpack(OSDMap args) |
105 | { | 105 | { |
106 | if (args.ContainsKey("region_handle")) | 106 | if (args.ContainsKey("region_handle")) |
107 | UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); | 107 | UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); |
@@ -257,7 +257,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
257 | 257 | ||
258 | public string CallbackURI; | 258 | public string CallbackURI; |
259 | 259 | ||
260 | public OSDMap PackUpdateMessage() | 260 | public virtual OSDMap Pack() |
261 | { | 261 | { |
262 | OSDMap args = new OSDMap(); | 262 | OSDMap args = new OSDMap(); |
263 | args["message_type"] = OSD.FromString("AgentData"); | 263 | args["message_type"] = OSD.FromString("AgentData"); |
@@ -346,7 +346,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
346 | /// Avoiding reflection makes it painful to write, but that's the price! | 346 | /// Avoiding reflection makes it painful to write, but that's the price! |
347 | /// </summary> | 347 | /// </summary> |
348 | /// <param name="hash"></param> | 348 | /// <param name="hash"></param> |
349 | public void UnpackUpdateMessage(OSDMap args) | 349 | public virtual void Unpack(OSDMap args) |
350 | { | 350 | { |
351 | if (args.ContainsKey("region_handle")) | 351 | if (args.ContainsKey("region_handle")) |
352 | UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); | 352 | UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); |
@@ -497,4 +497,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
497 | } | 497 | } |
498 | } | 498 | } |
499 | 499 | ||
500 | public class CompleteAgentData : AgentData | ||
501 | { | ||
502 | public override OSDMap Pack() | ||
503 | { | ||
504 | return base.Pack(); | ||
505 | } | ||
506 | |||
507 | public override void Unpack(OSDMap map) | ||
508 | { | ||
509 | base.Unpack(map); | ||
510 | } | ||
511 | } | ||
512 | |||
500 | } | 513 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9bec481..a60f7d8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -2549,6 +2549,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2549 | 2549 | ||
2550 | } | 2550 | } |
2551 | 2551 | ||
2552 | public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent) | ||
2553 | { | ||
2554 | agent = null; | ||
2555 | ScenePresence sp = GetScenePresence(id); | ||
2556 | if ((sp != null) && (!sp.IsChildAgent)) | ||
2557 | { | ||
2558 | sp.IsChildAgent = true; | ||
2559 | return sp.CopyAgent(out agent); | ||
2560 | } | ||
2561 | |||
2562 | return false; | ||
2563 | } | ||
2564 | |||
2552 | public virtual bool IncomingReleaseAgent(UUID id) | 2565 | public virtual bool IncomingReleaseAgent(UUID id) |
2553 | { | 2566 | { |
2554 | return m_sceneGridService.ReleaseAgent(id); | 2567 | return m_sceneGridService.ReleaseAgent(id); |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3ef3f6c..d6607b3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -2879,6 +2879,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2879 | 2879 | ||
2880 | } | 2880 | } |
2881 | 2881 | ||
2882 | public bool CopyAgent(out IAgentData agent) | ||
2883 | { | ||
2884 | agent = new CompleteAgentData(); | ||
2885 | CopyTo((AgentData)agent); | ||
2886 | return true; | ||
2887 | } | ||
2888 | |||
2882 | #endregion Child Agent Updates | 2889 | #endregion Child Agent Updates |
2883 | 2890 | ||
2884 | /// <summary> | 2891 | /// <summary> |