aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGGridServices.cs55
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs2
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs2
-rw-r--r--OpenSim/Region/Environment/Interfaces/IInterregionComms.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs15
-rw-r--r--OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs171
-rw-r--r--OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs3
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs6
8 files changed, 227 insertions, 29 deletions
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs
index 691cd4a..fc68ba2 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs
@@ -890,17 +890,8 @@ namespace OpenSim.Region.Communications.Hypergrid
890 890
891 public virtual bool ExpectPrimCrossing(ulong regionHandle, UUID primID, Vector3 position, bool isFlying) { return false; } 891 public virtual bool ExpectPrimCrossing(ulong regionHandle, UUID primID, Vector3 position, bool isFlying) { return false; }
892 892
893 public virtual bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) 893 public bool SendUserInformation(RegionInfo regInfo, AgentCircuitData agentData)
894 { 894 {
895 // If we're here, it's because regionHandle is a remote, non-grided region
896 m_log.Info("[HGrid]: InformRegionOfChildAgent for " + regionHandle);
897
898 RegionInfo regInfo = GetHyperlinkRegion(regionHandle);
899 if (regInfo == null)
900 return false;
901
902 //ulong realHandle = regionHandle;
903
904 CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID); 895 CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID);
905 if ((uinfo == null) || !IsGoingHome(uinfo, regInfo)) 896 if ((uinfo == null) || !IsGoingHome(uinfo, regInfo))
906 { 897 {
@@ -914,6 +905,33 @@ namespace OpenSim.Region.Communications.Hypergrid
914 else 905 else
915 m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); 906 m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
916 907
908 // May need to change agent's name
909 if (IsLocalUser(uinfo))
910 {
911 agentData.firstname = agentData.firstname + "." + agentData.lastname;
912 agentData.lastname = "@" + serversInfo.UserURL.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI;
913 }
914
915 return true;
916 }
917
918 public virtual bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData)
919 {
920 // If we're here, it's because regionHandle is a remote, non-grided region
921 m_log.Info("[HGrid]: InformRegionOfChildAgent for " + regionHandle);
922
923 RegionInfo regInfo = GetHyperlinkRegion(regionHandle);
924 if (regInfo == null)
925 return false;
926
927 //ulong realHandle = regionHandle;
928
929 if (!SendUserInformation(regInfo, agentData))
930 {
931 m_log.Warn("[HGrid]: Failed to inform remote region of user.");
932 //return false;
933 }
934
917 try 935 try
918 { 936 {
919 // ... and then 937 // ... and then
@@ -939,12 +957,14 @@ namespace OpenSim.Region.Communications.Hypergrid
939 if (remObject != null) 957 if (remObject != null)
940 { 958 {
941 sAgentCircuitData sag = new sAgentCircuitData(agentData); 959 sAgentCircuitData sag = new sAgentCircuitData(agentData);
942 // May need to change agent's name 960 //CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID);
943 if (IsLocalUser(uinfo)) 961
944 { 962 //// May need to change agent's name
945 sag.firstname = agentData.firstname + "." + agentData.lastname; 963 //if (IsLocalUser(uinfo))
946 sag.lastname = serversInfo.UserURL; //HGNetworkServersInfo.Singleton.LocalUserServerURI; 964 //{
947 } 965 // sag.firstname = agentData.firstname + "." + agentData.lastname;
966 // sag.lastname = serversInfo.UserURL; //HGNetworkServersInfo.Singleton.LocalUserServerURI;
967 //}
948 retValue = remObject.InformRegionOfChildAgent(regionHandle, sag); 968 retValue = remObject.InformRegionOfChildAgent(regionHandle, sag);
949 } 969 }
950 else 970 else
@@ -1158,7 +1178,7 @@ namespace OpenSim.Region.Communications.Hypergrid
1158 /// <param name="regionHandle"></param> 1178 /// <param name="regionHandle"></param>
1159 /// <param name="agentData"></param> 1179 /// <param name="agentData"></param>
1160 /// <returns></returns> 1180 /// <returns></returns>
1161 protected bool HGIncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) 1181 public void AdjustUserInformation(AgentCircuitData agentData)
1162 { 1182 {
1163 CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID); 1183 CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID);
1164 if ((uinfo != null) && (uinfo.UserProfile != null) && 1184 if ((uinfo != null) && (uinfo.UserProfile != null) &&
@@ -1174,7 +1194,6 @@ namespace OpenSim.Region.Communications.Hypergrid
1174 } 1194 }
1175 //else 1195 //else
1176 // Console.WriteLine("---------------> Foreign User!"); 1196 // Console.WriteLine("---------------> Foreign User!");
1177 return true;
1178 } 1197 }
1179 #endregion 1198 #endregion
1180 1199
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs
index 83c087d..0448692 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs
@@ -274,7 +274,7 @@ namespace OpenSim.Region.Communications.Hypergrid
274 /// <returns></returns> 274 /// <returns></returns>
275 public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) 275 public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData)
276 { 276 {
277 HGIncomingChildAgent(regionHandle, agentData); 277 AdjustUserInformation(agentData);
278 278
279 m_log.Info("[HGrid]: Incoming HGrid Agent " + agentData.firstname + " " + agentData.lastname); 279 m_log.Info("[HGrid]: Incoming HGrid Agent " + agentData.firstname + " " + agentData.lastname);
280 280
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
index cabc630..c160696 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
@@ -764,7 +764,7 @@ namespace OpenSim.Region.Communications.Hypergrid
764 /// <returns></returns> 764 /// <returns></returns>
765 public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) 765 public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData)
766 { 766 {
767 HGIncomingChildAgent(regionHandle, agentData); 767 AdjustUserInformation(agentData);
768 768
769 m_log.Info("[HGrid]: " + gdebugRegionName + ": Incoming HGrid Agent " + agentData.firstname + " " + agentData.lastname); 769 m_log.Info("[HGrid]: " + gdebugRegionName + ": Incoming HGrid Agent " + agentData.firstname + " " + agentData.lastname);
770 770
diff --git a/OpenSim/Region/Environment/Interfaces/IInterregionComms.cs b/OpenSim/Region/Environment/Interfaces/IInterregionComms.cs
index aa618a7..7aeef15 100644
--- a/OpenSim/Region/Environment/Interfaces/IInterregionComms.cs
+++ b/OpenSim/Region/Environment/Interfaces/IInterregionComms.cs
@@ -35,6 +35,8 @@ namespace OpenSim.Region.Environment.Interfaces
35 35
36 public interface IInterregionCommsOut 36 public interface IInterregionCommsOut
37 { 37 {
38 bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit);
39
38 /// <summary> 40 /// <summary>
39 /// Full child agent update. 41 /// Full child agent update.
40 /// </summary> 42 /// </summary>
diff --git a/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs b/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs
index 135a05e..efc5c39 100644
--- a/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs
+++ b/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs
@@ -118,6 +118,21 @@ namespace OpenSim.Region.Environment.Modules.Communications.Local
118 118
119 #region IInterregionComms 119 #region IInterregionComms
120 120
121 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit)
122 {
123 foreach (Scene s in m_sceneList)
124 {
125 if (s.RegionInfo.RegionHandle == regionHandle)
126 {
127 //m_log.Debug("[LOCAL COMMS]: Found region to send SendCreateChildAgent");
128 s.NewUserConnection(aCircuit);
129 return true;
130 }
131 }
132 //m_log.Debug("[LOCAL COMMS]: region not found for SendCreateChildAgent");
133 return false;
134 }
135
121 public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData) 136 public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData)
122 { 137 {
123 foreach (Scene s in m_sceneList) 138 foreach (Scene s in m_sceneList)
diff --git a/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs b/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs
index bff8316..7eb5d30 100644
--- a/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs
+++ b/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs
@@ -128,6 +128,25 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
128 128
129 #region IInterregionComms 129 #region IInterregionComms
130 130
131 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit)
132 {
133 // Try local first
134 if (m_localBackend.SendCreateChildAgent(regionHandle, aCircuit))
135 return true;
136
137 // else do the remote thing
138 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle);
139 if (regInfo != null)
140 {
141 SendUserInformation(regInfo, aCircuit);
142
143 return DoCreateChildAgentCall(regInfo, aCircuit);
144 }
145 //else
146 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
147 return false;
148 }
149
131 public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData) 150 public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData)
132 { 151 {
133 // Try local first 152 // Try local first
@@ -197,6 +216,91 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
197 // Internal functions for the above public interface 216 // Internal functions for the above public interface
198 //------------------------------------------------------------------- 217 //-------------------------------------------------------------------
199 218
219 protected bool DoCreateChildAgentCall(RegionInfo region, AgentCircuitData aCircuit)
220 {
221 // Eventually, we want to use a caps url instead of the agentID
222 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/";
223 //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri);
224
225 WebRequest AgentCreateRequest = WebRequest.Create(uri);
226 AgentCreateRequest.Method = "POST";
227 AgentCreateRequest.ContentType = "application/json";
228 AgentCreateRequest.Timeout = 10000;
229
230 // Fill it in
231 OSDMap args = null;
232 try
233 {
234 args = aCircuit.PackAgentCircuitData();
235 }
236 catch (Exception e)
237 {
238 m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message);
239 }
240 // Add the regionhandle of the destination region
241 ulong regionHandle = GetRegionHandle(region.RegionHandle);
242 args["destination_handle"] = OSD.FromString(regionHandle.ToString());
243
244 string strBuffer = "";
245 byte[] buffer = new byte[1];
246 try
247 {
248 strBuffer = OSDParser.SerializeJsonString(args);
249 System.Text.UTF8Encoding str = new System.Text.UTF8Encoding();
250 buffer = str.GetBytes(strBuffer);
251
252 }
253 catch (Exception e)
254 {
255 m_log.WarnFormat("[OSG2]: Exception thrown on serialization of ChildCreate: {0}", e.Message);
256 // ignore. buffer will be empty, caller should check.
257 }
258
259 Stream os = null;
260 try
261 { // send the Post
262 AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
263 os = AgentCreateRequest.GetRequestStream();
264 os.Write(buffer, 0, strBuffer.Length); //Send it
265 os.Close();
266 //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri);
267 }
268 //catch (WebException ex)
269 catch
270 {
271 //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message);
272
273 return false;
274 }
275
276 // Let's wait for the response
277 //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall");
278
279 try
280 {
281 WebResponse webResponse = AgentCreateRequest.GetResponse();
282 if (webResponse == null)
283 {
284 m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post");
285 }
286
287 StreamReader sr = new StreamReader(webResponse.GetResponseStream());
288 //reply = sr.ReadToEnd().Trim();
289 sr.ReadToEnd().Trim();
290 sr.Close();
291 //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply);
292
293 }
294 catch (WebException ex)
295 {
296 m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message);
297 // ignore, really
298 }
299
300 return true;
301
302 }
303
200 protected bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData) 304 protected bool DoChildAgentUpdateCall(RegionInfo region, IAgentData cAgentData)
201 { 305 {
202 // Eventually, we want to use a caps url instead of the agentID 306 // Eventually, we want to use a caps url instead of the agentID
@@ -233,7 +337,7 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
233 } 337 }
234 catch (Exception e) 338 catch (Exception e)
235 { 339 {
236 m_log.WarnFormat("[OSG2]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); 340 m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildUpdate: {0}", e.Message);
237 // ignore. buffer will be empty, caller should check. 341 // ignore. buffer will be empty, caller should check.
238 } 342 }
239 343
@@ -388,10 +492,7 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
388 } 492 }
389 else if (method.Equals("POST")) 493 else if (method.Equals("POST"))
390 { 494 {
391 m_log.InfoFormat("[REST COMMS]: method {0} not implemented yet in agent message", method); 495 DoPost(request, responsedata, agentID);
392 responsedata["int_response_code"] = 404;
393 responsedata["str_response_string"] = "false";
394
395 return responsedata; 496 return responsedata;
396 } 497 }
397 else if (method.Equals("DELETE")) 498 else if (method.Equals("DELETE"))
@@ -438,6 +539,40 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
438 } 539 }
439 } 540 }
440 541
542 protected virtual void DoPost(Hashtable request, Hashtable responsedata, UUID id)
543 {
544 OSDMap args = GetOSDMap(request);
545 if (args == null)
546 {
547 responsedata["int_response_code"] = 400;
548 responsedata["str_response_string"] = "false";
549 return;
550 }
551
552 // retrieve the regionhandle
553 ulong regionhandle = 0;
554 if (args["destination_handle"] != null)
555 UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
556
557 AgentCircuitData aCircuit = new AgentCircuitData();
558 try
559 {
560 aCircuit.UnpackAgentCircuitData(args);
561 }
562 catch (Exception ex)
563 {
564 m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildCreate message {0}", ex.Message);
565 return;
566 }
567
568 // This is the meaning of POST agent
569 AdjustUserInformation(aCircuit);
570 bool result = m_localBackend.SendCreateChildAgent(regionhandle, aCircuit);
571
572 responsedata["int_response_code"] = 200;
573 responsedata["str_response_string"] = result.ToString();
574 }
575
441 protected virtual void DoPut(Hashtable request, Hashtable responsedata) 576 protected virtual void DoPut(Hashtable request, Hashtable responsedata)
442 { 577 {
443 OSDMap args = GetOSDMap(request); 578 OSDMap args = GetOSDMap(request);
@@ -553,6 +688,10 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
553 } 688 }
554 } 689 }
555 690
691 #endregion Misc
692
693 #region Hyperlinks
694
556 protected virtual ulong GetRegionHandle(ulong handle) 695 protected virtual ulong GetRegionHandle(ulong handle)
557 { 696 {
558 if (m_aScene.SceneGridService is HGSceneCommunicationService) 697 if (m_aScene.SceneGridService is HGSceneCommunicationService)
@@ -568,7 +707,27 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
568 707
569 return false; 708 return false;
570 } 709 }
571 #endregion /* Misc */ 710
711 protected virtual void SendUserInformation(RegionInfo regInfo, AgentCircuitData aCircuit)
712 {
713 try
714 {
715 if (IsHyperlink(regInfo.RegionHandle))
716 {
717 ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.SendUserInformation(regInfo, aCircuit);
718 }
719 }
720 catch // Bad cast
721 { }
722
723 }
724
725 protected virtual void AdjustUserInformation(AgentCircuitData aCircuit)
726 {
727 if (m_aScene.SceneGridService is HGSceneCommunicationService)
728 ((HGSceneCommunicationService)(m_aScene.SceneGridService)).m_hg.AdjustUserInformation(aCircuit);
729 }
730 #endregion /* Hyperlinks */
572 731
573 } 732 }
574} 733}
diff --git a/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs
index 5e1621b..c53605f 100644
--- a/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ b/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs
@@ -192,7 +192,8 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid
192 agentCircuit.CapsPath = Util.GetRandomCapsPath(); 192 agentCircuit.CapsPath = Util.GetRandomCapsPath();
193 } 193 }
194 194
195 if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit)) 195 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
196 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit))
196 { 197 {
197 avatar.ControllingClient.SendTeleportFailed("Destination is not accepting teleports."); 198 avatar.ControllingClient.SendTeleportFailed("Destination is not accepting teleports.");
198 return; 199 return;
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
index 8b3ac4f..9282f14 100644
--- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
@@ -296,7 +296,8 @@ namespace OpenSim.Region.Environment.Scenes
296 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort 296 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
297 + "/CAPS/" + a.CapsPath + "0000/"; 297 + "/CAPS/" + a.CapsPath + "0000/";
298 298
299 bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a); 299 //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a);
300 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a);
300 301
301 if (regionAccepted && newAgent) 302 if (regionAccepted && newAgent)
302 { 303 {
@@ -787,7 +788,8 @@ namespace OpenSim.Region.Environment.Scenes
787 } 788 }
788 789
789 // Let's create an agent there if one doesn't exist yet. 790 // Let's create an agent there if one doesn't exist yet.
790 if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit)) 791 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
792 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit))
791 { 793 {
792 avatar.ControllingClient.SendTeleportFailed("Destination is not accepting teleports."); 794 avatar.ControllingClient.SendTeleportFailed("Destination is not accepting teleports.");
793 return; 795 return;