aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
diff options
context:
space:
mode:
authorJeff Ames2008-11-25 16:00:55 +0000
committerJeff Ames2008-11-25 16:00:55 +0000
commit518a8b9f2ac09a5060e2e59c913dfbe7faf397ef (patch)
tree8b3e39fbd54452e031873d31ff099e7db064cdee /OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
parent* minor: eliminate mono compiler warnings (diff)
downloadopensim-SC-518a8b9f2ac09a5060e2e59c913dfbe7faf397ef.zip
opensim-SC-518a8b9f2ac09a5060e2e59c913dfbe7faf397ef.tar.gz
opensim-SC-518a8b9f2ac09a5060e2e59c913dfbe7faf397ef.tar.bz2
opensim-SC-518a8b9f2ac09a5060e2e59c913dfbe7faf397ef.tar.xz
Update svn properties.
Diffstat (limited to 'OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs')
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs1856
1 files changed, 928 insertions, 928 deletions
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
index 4dc26e0..5fb9615 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
@@ -1,928 +1,928 @@
1/** 1/**
2 * Copyright (c) 2008, Contributors. All rights reserved. 2 * Copyright (c) 2008, Contributors. All rights reserved.
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without modification, 5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met: 6 * are permitted provided that the following conditions are met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright notice, 8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice, 10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation 11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution. 12 * and/or other materials provided with the distribution.
13 * * Neither the name of the Organizations nor the names of Individual 13 * * Neither the name of the Organizations nor the names of Individual
14 * Contributors may be used to endorse or promote products derived from 14 * Contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission. 15 * this software without specific prior written permission.
16 * 16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 24 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25 * OF THE POSSIBILITY OF SUCH DAMAGE. 25 * OF THE POSSIBILITY OF SUCH DAMAGE.
26 * 26 *
27 */ 27 */
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net; 31using System.Net;
32using System.Net.Sockets; 32using System.Net.Sockets;
33using System.Reflection; 33using System.Reflection;
34using System.Runtime.Remoting; 34using System.Runtime.Remoting;
35using System.Runtime.Remoting.Channels; 35using System.Runtime.Remoting.Channels;
36using System.Runtime.Remoting.Channels.Tcp; 36using System.Runtime.Remoting.Channels.Tcp;
37using System.Security.Authentication; 37using System.Security.Authentication;
38 38
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using OpenSim.Framework.Communications.Cache; 41using OpenSim.Framework.Communications.Cache;
42using OpenSim.Framework.Servers; 42using OpenSim.Framework.Servers;
43using OpenSim.Region.Communications.Local; 43using OpenSim.Region.Communications.Local;
44using OpenSim.Region.Communications.OGS1; 44using OpenSim.Region.Communications.OGS1;
45using OpenSim.Region.Environment.Scenes; 45using OpenSim.Region.Environment.Scenes;
46 46
47using OpenMetaverse; 47using OpenMetaverse;
48using Nwc.XmlRpc; 48using Nwc.XmlRpc;
49using log4net; 49using log4net;
50 50
51namespace OpenSim.Region.Communications.Hypergrid 51namespace OpenSim.Region.Communications.Hypergrid
52{ 52{
53 public class HGGridServicesStandalone : HGGridServices 53 public class HGGridServicesStandalone : HGGridServices
54 { 54 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 56
57 /// <summary> 57 /// <summary>
58 /// Encapsulate local backend services for manipulation of local regions 58 /// Encapsulate local backend services for manipulation of local regions
59 /// </summary> 59 /// </summary>
60 protected LocalBackEndServices m_localBackend = new LocalBackEndServices(); 60 protected LocalBackEndServices m_localBackend = new LocalBackEndServices();
61 61
62 private Dictionary<ulong, int> m_deadRegionCache = new Dictionary<ulong, int>(); 62 private Dictionary<ulong, int> m_deadRegionCache = new Dictionary<ulong, int>();
63 63
64 public LocalBackEndServices LocalBackend 64 public LocalBackEndServices LocalBackend
65 { 65 {
66 get { return m_localBackend; } 66 get { return m_localBackend; }
67 } 67 }
68 68
69 public override string gdebugRegionName 69 public override string gdebugRegionName
70 { 70 {
71 get { return m_localBackend.gdebugRegionName; } 71 get { return m_localBackend.gdebugRegionName; }
72 set { m_localBackend.gdebugRegionName = value; } 72 set { m_localBackend.gdebugRegionName = value; }
73 } 73 }
74 74
75 public override bool RegionLoginsEnabled 75 public override bool RegionLoginsEnabled
76 { 76 {
77 get { return m_localBackend.RegionLoginsEnabled; } 77 get { return m_localBackend.RegionLoginsEnabled; }
78 set { m_localBackend.RegionLoginsEnabled = value; } 78 set { m_localBackend.RegionLoginsEnabled = value; }
79 } 79 }
80 80
81 81
82 public HGGridServicesStandalone(NetworkServersInfo servers_info, BaseHttpServer httpServe, AssetCache asscache, SceneManager sman) 82 public HGGridServicesStandalone(NetworkServersInfo servers_info, BaseHttpServer httpServe, AssetCache asscache, SceneManager sman)
83 : base(servers_info, httpServe, asscache, sman) 83 : base(servers_info, httpServe, asscache, sman)
84 { 84 {
85 //Respond to Grid Services requests 85 //Respond to Grid Services requests
86 httpServer.AddXmlRPCHandler("logoff_user", LogOffUser); 86 httpServer.AddXmlRPCHandler("logoff_user", LogOffUser);
87 httpServer.AddXmlRPCHandler("check", PingCheckReply); 87 httpServer.AddXmlRPCHandler("check", PingCheckReply);
88 httpServer.AddXmlRPCHandler("land_data", LandData); 88 httpServer.AddXmlRPCHandler("land_data", LandData);
89 89
90 StartRemoting(); 90 StartRemoting();
91 } 91 }
92 92
93 #region IGridServices interface 93 #region IGridServices interface
94 94
95 public override RegionCommsListener RegisterRegion(RegionInfo regionInfo) 95 public override RegionCommsListener RegisterRegion(RegionInfo regionInfo)
96 { 96 {
97 if (!regionInfo.RegionID.Equals(UUID.Zero)) 97 if (!regionInfo.RegionID.Equals(UUID.Zero))
98 { 98 {
99 m_regionsOnInstance.Add(regionInfo); 99 m_regionsOnInstance.Add(regionInfo);
100 return m_localBackend.RegisterRegion(regionInfo); 100 return m_localBackend.RegisterRegion(regionInfo);
101 } 101 }
102 else 102 else
103 return base.RegisterRegion(regionInfo); 103 return base.RegisterRegion(regionInfo);
104 104
105 } 105 }
106 106
107 public override bool DeregisterRegion(RegionInfo regionInfo) 107 public override bool DeregisterRegion(RegionInfo regionInfo)
108 { 108 {
109 bool success = m_localBackend.DeregisterRegion(regionInfo); 109 bool success = m_localBackend.DeregisterRegion(regionInfo);
110 if (!success) 110 if (!success)
111 success = base.DeregisterRegion(regionInfo); 111 success = base.DeregisterRegion(regionInfo);
112 return success; 112 return success;
113 } 113 }
114 114
115 public override List<SimpleRegionInfo> RequestNeighbours(uint x, uint y) 115 public override List<SimpleRegionInfo> RequestNeighbours(uint x, uint y)
116 { 116 {
117 List<SimpleRegionInfo> neighbours = m_localBackend.RequestNeighbours(x, y); 117 List<SimpleRegionInfo> neighbours = m_localBackend.RequestNeighbours(x, y);
118 List<SimpleRegionInfo> remotes = base.RequestNeighbours(x, y); 118 List<SimpleRegionInfo> remotes = base.RequestNeighbours(x, y);
119 neighbours.AddRange(remotes); 119 neighbours.AddRange(remotes);
120 120
121 return neighbours; 121 return neighbours;
122 } 122 }
123 123
124 public override RegionInfo RequestNeighbourInfo(UUID Region_UUID) 124 public override RegionInfo RequestNeighbourInfo(UUID Region_UUID)
125 { 125 {
126 RegionInfo info = m_localBackend.RequestNeighbourInfo(Region_UUID); 126 RegionInfo info = m_localBackend.RequestNeighbourInfo(Region_UUID);
127 if (info == null) 127 if (info == null)
128 info = base.RequestNeighbourInfo(Region_UUID); 128 info = base.RequestNeighbourInfo(Region_UUID);
129 return info; 129 return info;
130 } 130 }
131 131
132 public override RegionInfo RequestNeighbourInfo(ulong regionHandle) 132 public override RegionInfo RequestNeighbourInfo(ulong regionHandle)
133 { 133 {
134 RegionInfo info = m_localBackend.RequestNeighbourInfo(regionHandle); 134 RegionInfo info = m_localBackend.RequestNeighbourInfo(regionHandle);
135 //m_log.Info("[HGrid] Request neighbor info, local backend returned " + info); 135 //m_log.Info("[HGrid] Request neighbor info, local backend returned " + info);
136 if (info == null) 136 if (info == null)
137 info = base.RequestNeighbourInfo(regionHandle); 137 info = base.RequestNeighbourInfo(regionHandle);
138 return info; 138 return info;
139 } 139 }
140 140
141 public override RegionInfo RequestClosestRegion(string regionName) 141 public override RegionInfo RequestClosestRegion(string regionName)
142 { 142 {
143 RegionInfo info = m_localBackend.RequestClosestRegion(regionName); 143 RegionInfo info = m_localBackend.RequestClosestRegion(regionName);
144 if (info == null) 144 if (info == null)
145 info = base.RequestClosestRegion(regionName); 145 info = base.RequestClosestRegion(regionName);
146 return info; 146 return info;
147 } 147 }
148 148
149 public override List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) 149 public override List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
150 { 150 {
151 //m_log.Info("[HGrid] Request map blocks " + minX + "-" + minY + "-" + maxX + "-" + maxY); 151 //m_log.Info("[HGrid] Request map blocks " + minX + "-" + minY + "-" + maxX + "-" + maxY);
152 List<MapBlockData> neighbours = m_localBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); 152 List<MapBlockData> neighbours = m_localBackend.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
153 List<MapBlockData> remotes = base.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); 153 List<MapBlockData> remotes = base.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
154 neighbours.AddRange(remotes); 154 neighbours.AddRange(remotes);
155 155
156 return neighbours; 156 return neighbours;
157 } 157 }
158 158
159 public override LandData RequestLandData(ulong regionHandle, uint x, uint y) 159 public override LandData RequestLandData(ulong regionHandle, uint x, uint y)
160 { 160 {
161 LandData land = m_localBackend.RequestLandData(regionHandle, x, y); 161 LandData land = m_localBackend.RequestLandData(regionHandle, x, y);
162 if (land == null) 162 if (land == null)
163 land = base.RequestLandData(regionHandle, x, y); 163 land = base.RequestLandData(regionHandle, x, y);
164 return land; 164 return land;
165 } 165 }
166 166
167 public override List<RegionInfo> RequestNamedRegions(string name, int maxNumber) 167 public override List<RegionInfo> RequestNamedRegions(string name, int maxNumber)
168 { 168 {
169 List<RegionInfo> infos = m_localBackend.RequestNamedRegions(name, maxNumber); 169 List<RegionInfo> infos = m_localBackend.RequestNamedRegions(name, maxNumber);
170 List<RegionInfo> remotes = base.RequestNamedRegions(name, maxNumber); 170 List<RegionInfo> remotes = base.RequestNamedRegions(name, maxNumber);
171 infos.AddRange(remotes); 171 infos.AddRange(remotes);
172 return infos; 172 return infos;
173 } 173 }
174 174
175 #endregion 175 #endregion
176 176
177 #region XML Request Handlers 177 #region XML Request Handlers
178 178
179 /// <summary> 179 /// <summary>
180 /// A ping / version check 180 /// A ping / version check
181 /// </summary> 181 /// </summary>
182 /// <param name="request"></param> 182 /// <param name="request"></param>
183 /// <returns></returns> 183 /// <returns></returns>
184 public virtual XmlRpcResponse PingCheckReply(XmlRpcRequest request) 184 public virtual XmlRpcResponse PingCheckReply(XmlRpcRequest request)
185 { 185 {
186 XmlRpcResponse response = new XmlRpcResponse(); 186 XmlRpcResponse response = new XmlRpcResponse();
187 187
188 Hashtable respData = new Hashtable(); 188 Hashtable respData = new Hashtable();
189 respData["online"] = "true"; 189 respData["online"] = "true";
190 190
191 m_localBackend.PingCheckReply(respData); 191 m_localBackend.PingCheckReply(respData);
192 192
193 response.Value = respData; 193 response.Value = respData;
194 194
195 return response; 195 return response;
196 } 196 }
197 197
198 198
199 // Grid Request Processing 199 // Grid Request Processing
200 /// <summary> 200 /// <summary>
201 /// Ooops, our Agent must be dead if we're getting this request! 201 /// Ooops, our Agent must be dead if we're getting this request!
202 /// </summary> 202 /// </summary>
203 /// <param name="request"></param> 203 /// <param name="request"></param>
204 /// <returns></returns> 204 /// <returns></returns>
205 public XmlRpcResponse LogOffUser(XmlRpcRequest request) 205 public XmlRpcResponse LogOffUser(XmlRpcRequest request)
206 { 206 {
207 m_log.Debug("[HGrid]: LogOff User Called"); 207 m_log.Debug("[HGrid]: LogOff User Called");
208 208
209 Hashtable requestData = (Hashtable)request.Params[0]; 209 Hashtable requestData = (Hashtable)request.Params[0];
210 string message = (string)requestData["message"]; 210 string message = (string)requestData["message"];
211 UUID agentID = UUID.Zero; 211 UUID agentID = UUID.Zero;
212 UUID RegionSecret = UUID.Zero; 212 UUID RegionSecret = UUID.Zero;
213 UUID.TryParse((string)requestData["agent_id"], out agentID); 213 UUID.TryParse((string)requestData["agent_id"], out agentID);
214 UUID.TryParse((string)requestData["region_secret"], out RegionSecret); 214 UUID.TryParse((string)requestData["region_secret"], out RegionSecret);
215 215
216 ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); 216 ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
217 217
218 m_localBackend.TriggerLogOffUser(regionHandle, agentID, RegionSecret, message); 218 m_localBackend.TriggerLogOffUser(regionHandle, agentID, RegionSecret, message);
219 219
220 return new XmlRpcResponse(); 220 return new XmlRpcResponse();
221 } 221 }
222 222
223 /// <summary> 223 /// <summary>
224 /// Someone asked us about parcel-information 224 /// Someone asked us about parcel-information
225 /// </summary> 225 /// </summary>
226 /// <param name="request"></param> 226 /// <param name="request"></param>
227 /// <returns></returns> 227 /// <returns></returns>
228 public XmlRpcResponse LandData(XmlRpcRequest request) 228 public XmlRpcResponse LandData(XmlRpcRequest request)
229 { 229 {
230 Hashtable requestData = (Hashtable)request.Params[0]; 230 Hashtable requestData = (Hashtable)request.Params[0];
231 ulong regionHandle = Convert.ToUInt64(requestData["region_handle"]); 231 ulong regionHandle = Convert.ToUInt64(requestData["region_handle"]);
232 uint x = Convert.ToUInt32(requestData["x"]); 232 uint x = Convert.ToUInt32(requestData["x"]);
233 uint y = Convert.ToUInt32(requestData["y"]); 233 uint y = Convert.ToUInt32(requestData["y"]);
234 m_log.DebugFormat("[HGrid]: Got XML reqeuest for land data at {0}, {1} in region {2}", x, y, regionHandle); 234 m_log.DebugFormat("[HGrid]: Got XML reqeuest for land data at {0}, {1} in region {2}", x, y, regionHandle);
235 235
236 LandData landData = m_localBackend.RequestLandData(regionHandle, x, y); 236 LandData landData = m_localBackend.RequestLandData(regionHandle, x, y);
237 Hashtable hash = new Hashtable(); 237 Hashtable hash = new Hashtable();
238 if (landData != null) 238 if (landData != null)
239 { 239 {
240 // for now, only push out the data we need for answering a ParcelInfoReqeust 240 // for now, only push out the data we need for answering a ParcelInfoReqeust
241 hash["AABBMax"] = landData.AABBMax.ToString(); 241 hash["AABBMax"] = landData.AABBMax.ToString();
242 hash["AABBMin"] = landData.AABBMin.ToString(); 242 hash["AABBMin"] = landData.AABBMin.ToString();
243 hash["Area"] = landData.Area.ToString(); 243 hash["Area"] = landData.Area.ToString();
244 hash["AuctionID"] = landData.AuctionID.ToString(); 244 hash["AuctionID"] = landData.AuctionID.ToString();
245 hash["Description"] = landData.Description; 245 hash["Description"] = landData.Description;
246 hash["Flags"] = landData.Flags.ToString(); 246 hash["Flags"] = landData.Flags.ToString();
247 hash["GlobalID"] = landData.GlobalID.ToString(); 247 hash["GlobalID"] = landData.GlobalID.ToString();
248 hash["Name"] = landData.Name; 248 hash["Name"] = landData.Name;
249 hash["OwnerID"] = landData.OwnerID.ToString(); 249 hash["OwnerID"] = landData.OwnerID.ToString();
250 hash["SalePrice"] = landData.SalePrice.ToString(); 250 hash["SalePrice"] = landData.SalePrice.ToString();
251 hash["SnapshotID"] = landData.SnapshotID.ToString(); 251 hash["SnapshotID"] = landData.SnapshotID.ToString();
252 hash["UserLocation"] = landData.UserLocation.ToString(); 252 hash["UserLocation"] = landData.UserLocation.ToString();
253 } 253 }
254 254
255 XmlRpcResponse response = new XmlRpcResponse(); 255 XmlRpcResponse response = new XmlRpcResponse();
256 response.Value = hash; 256 response.Value = hash;
257 return response; 257 return response;
258 } 258 }
259 259
260 #endregion 260 #endregion
261 261
262 #region Remoting 262 #region Remoting
263 263
264 /// <summary> 264 /// <summary>
265 /// Start listening for .net remoting calls from other regions. 265 /// Start listening for .net remoting calls from other regions.
266 /// </summary> 266 /// </summary>
267 private void StartRemoting() 267 private void StartRemoting()
268 { 268 {
269 m_log.Info("[HGrid]: Start remoting..."); 269 m_log.Info("[HGrid]: Start remoting...");
270 TcpChannel ch; 270 TcpChannel ch;
271 try 271 try
272 { 272 {
273 ch = new TcpChannel((int)NetworkServersInfo.RemotingListenerPort); 273 ch = new TcpChannel((int)NetworkServersInfo.RemotingListenerPort);
274 ChannelServices.RegisterChannel(ch, false); // Disabled security as Mono doesn't support this. 274 ChannelServices.RegisterChannel(ch, false); // Disabled security as Mono doesn't support this.
275 } 275 }
276 catch (Exception ex) 276 catch (Exception ex)
277 { 277 {
278 m_log.Error("[HGrid]: Exception while attempting to listen on TCP port " + (int)NetworkServersInfo.RemotingListenerPort + "."); 278 m_log.Error("[HGrid]: Exception while attempting to listen on TCP port " + (int)NetworkServersInfo.RemotingListenerPort + ".");
279 throw (ex); 279 throw (ex);
280 } 280 }
281 281
282 WellKnownServiceTypeEntry wellType = 282 WellKnownServiceTypeEntry wellType =
283 new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", 283 new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions",
284 WellKnownObjectMode.Singleton); 284 WellKnownObjectMode.Singleton);
285 RemotingConfiguration.RegisterWellKnownServiceType(wellType); 285 RemotingConfiguration.RegisterWellKnownServiceType(wellType);
286 InterRegionSingleton.Instance.OnArrival += TriggerExpectAvatarCrossing; 286 InterRegionSingleton.Instance.OnArrival += TriggerExpectAvatarCrossing;
287 InterRegionSingleton.Instance.OnChildAgent += IncomingChildAgent; 287 InterRegionSingleton.Instance.OnChildAgent += IncomingChildAgent;
288 InterRegionSingleton.Instance.OnPrimGroupArrival += IncomingPrim; 288 InterRegionSingleton.Instance.OnPrimGroupArrival += IncomingPrim;
289 InterRegionSingleton.Instance.OnPrimGroupNear += TriggerExpectPrimCrossing; 289 InterRegionSingleton.Instance.OnPrimGroupNear += TriggerExpectPrimCrossing;
290 InterRegionSingleton.Instance.OnRegionUp += TriggerRegionUp; 290 InterRegionSingleton.Instance.OnRegionUp += TriggerRegionUp;
291 InterRegionSingleton.Instance.OnChildAgentUpdate += TriggerChildAgentUpdate; 291 InterRegionSingleton.Instance.OnChildAgentUpdate += TriggerChildAgentUpdate;
292 InterRegionSingleton.Instance.OnTellRegionToCloseChildConnection += TriggerTellRegionToCloseChildConnection; 292 InterRegionSingleton.Instance.OnTellRegionToCloseChildConnection += TriggerTellRegionToCloseChildConnection;
293 } 293 }
294 294
295 295
296 #endregion 296 #endregion
297 297
298 #region IInterRegionCommunications interface (Methods called by regions in this instance) 298 #region IInterRegionCommunications interface (Methods called by regions in this instance)
299 299
300 public override bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) 300 public override bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData)
301 { 301 {
302 int failures = 0; 302 int failures = 0;
303 lock (m_deadRegionCache) 303 lock (m_deadRegionCache)
304 { 304 {
305 if (m_deadRegionCache.ContainsKey(regionHandle)) 305 if (m_deadRegionCache.ContainsKey(regionHandle))
306 { 306 {
307 failures = m_deadRegionCache[regionHandle]; 307 failures = m_deadRegionCache[regionHandle];
308 } 308 }
309 } 309 }
310 if (failures <= 3) 310 if (failures <= 3)
311 { 311 {
312 RegionInfo regInfo = null; 312 RegionInfo regInfo = null;
313 try 313 try
314 { 314 {
315 if (m_localBackend.ChildAgentUpdate(regionHandle, cAgentData)) 315 if (m_localBackend.ChildAgentUpdate(regionHandle, cAgentData))
316 { 316 {
317 return true; 317 return true;
318 } 318 }
319 319
320 regInfo = RequestNeighbourInfo(regionHandle); 320 regInfo = RequestNeighbourInfo(regionHandle);
321 if (regInfo != null) 321 if (regInfo != null)
322 { 322 {
323 //don't want to be creating a new link to the remote instance every time like we are here 323 //don't want to be creating a new link to the remote instance every time like we are here
324 bool retValue = false; 324 bool retValue = false;
325 325
326 326
327 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( 327 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject(
328 typeof(OGS1InterRegionRemoting), 328 typeof(OGS1InterRegionRemoting),
329 "tcp://" + regInfo.RemotingAddress + 329 "tcp://" + regInfo.RemotingAddress +
330 ":" + regInfo.RemotingPort + 330 ":" + regInfo.RemotingPort +
331 "/InterRegions"); 331 "/InterRegions");
332 332
333 if (remObject != null) 333 if (remObject != null)
334 { 334 {
335 retValue = remObject.ChildAgentUpdate(regionHandle, cAgentData); 335 retValue = remObject.ChildAgentUpdate(regionHandle, cAgentData);
336 } 336 }
337 else 337 else
338 { 338 {
339 m_log.Warn("[HGrid]: remoting object not found"); 339 m_log.Warn("[HGrid]: remoting object not found");
340 } 340 }
341 remObject = null; 341 remObject = null;
342 342
343 return retValue; 343 return retValue;
344 } 344 }
345 NoteDeadRegion(regionHandle); 345 NoteDeadRegion(regionHandle);
346 346
347 return false; 347 return false;
348 } 348 }
349 catch (RemotingException e) 349 catch (RemotingException e)
350 { 350 {
351 NoteDeadRegion(regionHandle); 351 NoteDeadRegion(regionHandle);
352 352
353 m_log.WarnFormat( 353 m_log.WarnFormat(
354 "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", 354 "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}",
355 regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); 355 regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY);
356 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 356 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
357 357
358 return false; 358 return false;
359 } 359 }
360 catch (SocketException e) 360 catch (SocketException e)
361 { 361 {
362 NoteDeadRegion(regionHandle); 362 NoteDeadRegion(regionHandle);
363 363
364 m_log.WarnFormat( 364 m_log.WarnFormat(
365 "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", 365 "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}",
366 regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); 366 regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY);
367 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 367 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
368 368
369 return false; 369 return false;
370 } 370 }
371 catch (InvalidCredentialException e) 371 catch (InvalidCredentialException e)
372 { 372 {
373 NoteDeadRegion(regionHandle); 373 NoteDeadRegion(regionHandle);
374 374
375 m_log.WarnFormat( 375 m_log.WarnFormat(
376 "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", 376 "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}",
377 regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); 377 regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY);
378 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 378 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
379 379
380 return false; 380 return false;
381 } 381 }
382 catch (AuthenticationException e) 382 catch (AuthenticationException e)
383 { 383 {
384 NoteDeadRegion(regionHandle); 384 NoteDeadRegion(regionHandle);
385 385
386 m_log.WarnFormat( 386 m_log.WarnFormat(
387 "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", 387 "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}",
388 regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); 388 regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY);
389 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 389 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
390 390
391 return false; 391 return false;
392 } 392 }
393 catch (Exception e) 393 catch (Exception e)
394 { 394 {
395 NoteDeadRegion(regionHandle); 395 NoteDeadRegion(regionHandle);
396 396
397 m_log.WarnFormat("[HGrid]: Unable to connect to adjacent region: {0} {1},{2}", 397 m_log.WarnFormat("[HGrid]: Unable to connect to adjacent region: {0} {1},{2}",
398 regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); 398 regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY);
399 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 399 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
400 400
401 return false; 401 return false;
402 } 402 }
403 } 403 }
404 else 404 else
405 { 405 {
406 //m_log.Info("[INTERREGION]: Skipped Sending Child Update to a region because it failed too many times:" + regionHandle.ToString()); 406 //m_log.Info("[INTERREGION]: Skipped Sending Child Update to a region because it failed too many times:" + regionHandle.ToString());
407 return false; 407 return false;
408 } 408 }
409 } 409 }
410 410
411 /// <summary> 411 /// <summary>
412 /// Inform a region that a child agent will be on the way from a client. 412 /// Inform a region that a child agent will be on the way from a client.
413 /// </summary> 413 /// </summary>
414 /// <param name="regionHandle"></param> 414 /// <param name="regionHandle"></param>
415 /// <param name="agentData"></param> 415 /// <param name="agentData"></param>
416 /// <returns></returns> 416 /// <returns></returns>
417 public override bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) 417 public override bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData)
418 { 418 {
419 419
420 if (m_localBackend.InformRegionOfChildAgent(regionHandle, agentData)) 420 if (m_localBackend.InformRegionOfChildAgent(regionHandle, agentData))
421 { 421 {
422 return true; 422 return true;
423 } 423 }
424 return base.InformRegionOfChildAgent(regionHandle, agentData); 424 return base.InformRegionOfChildAgent(regionHandle, agentData);
425 } 425 }
426 426
427 // UGLY! 427 // UGLY!
428 public override bool RegionUp(SerializableRegionInfo region, ulong regionhandle) 428 public override bool RegionUp(SerializableRegionInfo region, ulong regionhandle)
429 { 429 {
430 if (m_localBackend.RegionUp(region, regionhandle)) 430 if (m_localBackend.RegionUp(region, regionhandle))
431 return true; 431 return true;
432 return base.RegionUp(region, regionhandle); 432 return base.RegionUp(region, regionhandle);
433 } 433 }
434 434
435 /// <summary> 435 /// <summary>
436 /// 436 ///
437 /// </summary> 437 /// </summary>
438 /// <param name="regionHandle"></param> 438 /// <param name="regionHandle"></param>
439 /// <param name="agentData"></param> 439 /// <param name="agentData"></param>
440 /// <returns></returns> 440 /// <returns></returns>
441 public override bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod) 441 public override bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod)
442 { 442 {
443 int failures = 0; 443 int failures = 0;
444 lock (m_deadRegionCache) 444 lock (m_deadRegionCache)
445 { 445 {
446 if (m_deadRegionCache.ContainsKey(regionHandle)) 446 if (m_deadRegionCache.ContainsKey(regionHandle))
447 { 447 {
448 failures = m_deadRegionCache[regionHandle]; 448 failures = m_deadRegionCache[regionHandle];
449 } 449 }
450 } 450 }
451 if (failures <= 1) 451 if (failures <= 1)
452 { 452 {
453 RegionInfo regInfo = null; 453 RegionInfo regInfo = null;
454 try 454 try
455 { 455 {
456 if (m_localBackend.InformRegionOfPrimCrossing(regionHandle, primID, objData, XMLMethod)) 456 if (m_localBackend.InformRegionOfPrimCrossing(regionHandle, primID, objData, XMLMethod))
457 { 457 {
458 return true; 458 return true;
459 } 459 }
460 460
461 regInfo = RequestNeighbourInfo(regionHandle); 461 regInfo = RequestNeighbourInfo(regionHandle);
462 if (regInfo != null) 462 if (regInfo != null)
463 { 463 {
464 //don't want to be creating a new link to the remote instance every time like we are here 464 //don't want to be creating a new link to the remote instance every time like we are here
465 bool retValue = false; 465 bool retValue = false;
466 466
467 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( 467 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject(
468 typeof(OGS1InterRegionRemoting), 468 typeof(OGS1InterRegionRemoting),
469 "tcp://" + regInfo.RemotingAddress + 469 "tcp://" + regInfo.RemotingAddress +
470 ":" + regInfo.RemotingPort + 470 ":" + regInfo.RemotingPort +
471 "/InterRegions"); 471 "/InterRegions");
472 472
473 if (remObject != null) 473 if (remObject != null)
474 { 474 {
475 retValue = remObject.InformRegionOfPrimCrossing(regionHandle, primID.Guid, objData, XMLMethod); 475 retValue = remObject.InformRegionOfPrimCrossing(regionHandle, primID.Guid, objData, XMLMethod);
476 } 476 }
477 else 477 else
478 { 478 {
479 m_log.Warn("[HGrid]: Remoting object not found"); 479 m_log.Warn("[HGrid]: Remoting object not found");
480 } 480 }
481 remObject = null; 481 remObject = null;
482 482
483 return retValue; 483 return retValue;
484 } 484 }
485 NoteDeadRegion(regionHandle); 485 NoteDeadRegion(regionHandle);
486 return false; 486 return false;
487 } 487 }
488 catch (RemotingException e) 488 catch (RemotingException e)
489 { 489 {
490 NoteDeadRegion(regionHandle); 490 NoteDeadRegion(regionHandle);
491 m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); 491 m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle);
492 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 492 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
493 return false; 493 return false;
494 } 494 }
495 catch (SocketException e) 495 catch (SocketException e)
496 { 496 {
497 NoteDeadRegion(regionHandle); 497 NoteDeadRegion(regionHandle);
498 m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); 498 m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle);
499 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 499 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
500 return false; 500 return false;
501 } 501 }
502 catch (InvalidCredentialException e) 502 catch (InvalidCredentialException e)
503 { 503 {
504 NoteDeadRegion(regionHandle); 504 NoteDeadRegion(regionHandle);
505 m_log.Warn("[HGrid]: Invalid Credential Exception: Invalid Credentials : " + regionHandle); 505 m_log.Warn("[HGrid]: Invalid Credential Exception: Invalid Credentials : " + regionHandle);
506 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 506 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
507 return false; 507 return false;
508 } 508 }
509 catch (AuthenticationException e) 509 catch (AuthenticationException e)
510 { 510 {
511 NoteDeadRegion(regionHandle); 511 NoteDeadRegion(regionHandle);
512 m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region: " + regionHandle); 512 m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region: " + regionHandle);
513 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 513 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
514 return false; 514 return false;
515 } 515 }
516 catch (Exception e) 516 catch (Exception e)
517 { 517 {
518 NoteDeadRegion(regionHandle); 518 NoteDeadRegion(regionHandle);
519 m_log.Warn("[HGrid]: Unknown exception: Unable to connect to adjacent region: " + regionHandle); 519 m_log.Warn("[HGrid]: Unknown exception: Unable to connect to adjacent region: " + regionHandle);
520 m_log.DebugFormat("[HGrid]: {0}", e); 520 m_log.DebugFormat("[HGrid]: {0}", e);
521 return false; 521 return false;
522 } 522 }
523 } 523 }
524 else 524 else
525 { 525 {
526 return false; 526 return false;
527 } 527 }
528 } 528 }
529 529
530 /// <summary> 530 /// <summary>
531 /// 531 ///
532 /// </summary> 532 /// </summary>
533 /// <param name="regionHandle"></param> 533 /// <param name="regionHandle"></param>
534 /// <param name="agentID"></param> 534 /// <param name="agentID"></param>
535 /// <param name="position"></param> 535 /// <param name="position"></param>
536 /// <returns></returns> 536 /// <returns></returns>
537 public override bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) 537 public override bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying)
538 { 538 {
539 539
540 RegionInfo[] regions = m_regionsOnInstance.ToArray(); 540 RegionInfo[] regions = m_regionsOnInstance.ToArray();
541 bool banned = false; 541 bool banned = false;
542 bool localregion = false; 542 bool localregion = false;
543 543
544 for (int i = 0; i < regions.Length; i++) 544 for (int i = 0; i < regions.Length; i++)
545 { 545 {
546 if (regions[i] != null) 546 if (regions[i] != null)
547 { 547 {
548 if (regions[i].RegionHandle == regionHandle) 548 if (regions[i].RegionHandle == regionHandle)
549 { 549 {
550 localregion = true; 550 localregion = true;
551 if (regions[i].EstateSettings.IsBanned(agentID)) 551 if (regions[i].EstateSettings.IsBanned(agentID))
552 { 552 {
553 banned = true; 553 banned = true;
554 break; 554 break;
555 } 555 }
556 } 556 }
557 } 557 }
558 } 558 }
559 559
560 if (banned) 560 if (banned)
561 return false; 561 return false;
562 if (localregion) 562 if (localregion)
563 return m_localBackend.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); 563 return m_localBackend.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying);
564 564
565 return base.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); 565 return base.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying);
566 566
567 } 567 }
568 568
569 public override bool ExpectPrimCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isPhysical) 569 public override bool ExpectPrimCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isPhysical)
570 { 570 {
571 RegionInfo regInfo = null; 571 RegionInfo regInfo = null;
572 try 572 try
573 { 573 {
574 if (m_localBackend.TriggerExpectPrimCrossing(regionHandle, agentID, position, isPhysical)) 574 if (m_localBackend.TriggerExpectPrimCrossing(regionHandle, agentID, position, isPhysical))
575 { 575 {
576 return true; 576 return true;
577 } 577 }
578 578
579 regInfo = RequestNeighbourInfo(regionHandle); 579 regInfo = RequestNeighbourInfo(regionHandle);
580 if (regInfo != null) 580 if (regInfo != null)
581 { 581 {
582 bool retValue = false; 582 bool retValue = false;
583 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( 583 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject(
584 typeof(OGS1InterRegionRemoting), 584 typeof(OGS1InterRegionRemoting),
585 "tcp://" + regInfo.RemotingAddress + 585 "tcp://" + regInfo.RemotingAddress +
586 ":" + regInfo.RemotingPort + 586 ":" + regInfo.RemotingPort +
587 "/InterRegions"); 587 "/InterRegions");
588 588
589 if (remObject != null) 589 if (remObject != null)
590 { 590 {
591 retValue = 591 retValue =
592 remObject.ExpectAvatarCrossing(regionHandle, agentID.Guid, new sLLVector3(position), 592 remObject.ExpectAvatarCrossing(regionHandle, agentID.Guid, new sLLVector3(position),
593 isPhysical); 593 isPhysical);
594 } 594 }
595 else 595 else
596 { 596 {
597 m_log.Warn("[HGrid]: Remoting object not found"); 597 m_log.Warn("[HGrid]: Remoting object not found");
598 } 598 }
599 remObject = null; 599 remObject = null;
600 600
601 return retValue; 601 return retValue;
602 } 602 }
603 //TODO need to see if we know about where this region is and use .net remoting 603 //TODO need to see if we know about where this region is and use .net remoting
604 // to inform it. 604 // to inform it.
605 NoteDeadRegion(regionHandle); 605 NoteDeadRegion(regionHandle);
606 return false; 606 return false;
607 } 607 }
608 catch (RemotingException e) 608 catch (RemotingException e)
609 { 609 {
610 NoteDeadRegion(regionHandle); 610 NoteDeadRegion(regionHandle);
611 m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); 611 m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle);
612 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 612 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
613 return false; 613 return false;
614 } 614 }
615 catch (SocketException e) 615 catch (SocketException e)
616 { 616 {
617 NoteDeadRegion(regionHandle); 617 NoteDeadRegion(regionHandle);
618 m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); 618 m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle);
619 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 619 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
620 return false; 620 return false;
621 } 621 }
622 catch (InvalidCredentialException e) 622 catch (InvalidCredentialException e)
623 { 623 {
624 NoteDeadRegion(regionHandle); 624 NoteDeadRegion(regionHandle);
625 m_log.Warn("[HGrid]: Invalid Credential Exception: Invalid Credentials : " + regionHandle); 625 m_log.Warn("[HGrid]: Invalid Credential Exception: Invalid Credentials : " + regionHandle);
626 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 626 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
627 return false; 627 return false;
628 } 628 }
629 catch (AuthenticationException e) 629 catch (AuthenticationException e)
630 { 630 {
631 NoteDeadRegion(regionHandle); 631 NoteDeadRegion(regionHandle);
632 m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region: " + regionHandle); 632 m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region: " + regionHandle);
633 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 633 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
634 return false; 634 return false;
635 } 635 }
636 catch (Exception e) 636 catch (Exception e)
637 { 637 {
638 NoteDeadRegion(regionHandle); 638 NoteDeadRegion(regionHandle);
639 m_log.Warn("[HGrid]: Unknown exception: Unable to connect to adjacent region: " + regionHandle); 639 m_log.Warn("[HGrid]: Unknown exception: Unable to connect to adjacent region: " + regionHandle);
640 m_log.DebugFormat("[HGrid]: {0}", e); 640 m_log.DebugFormat("[HGrid]: {0}", e);
641 return false; 641 return false;
642 } 642 }
643 } 643 }
644 644
645 public override bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) 645 public override bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID)
646 { 646 {
647 RegionInfo regInfo = null; 647 RegionInfo regInfo = null;
648 try 648 try
649 { 649 {
650 if (m_localBackend.TriggerTellRegionToCloseChildConnection(regionHandle, agentID)) 650 if (m_localBackend.TriggerTellRegionToCloseChildConnection(regionHandle, agentID))
651 { 651 {
652 return true; 652 return true;
653 } 653 }
654 654
655 regInfo = RequestNeighbourInfo(regionHandle); 655 regInfo = RequestNeighbourInfo(regionHandle);
656 if (regInfo != null) 656 if (regInfo != null)
657 { 657 {
658 // bool retValue = false; 658 // bool retValue = false;
659 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( 659 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject(
660 typeof(OGS1InterRegionRemoting), 660 typeof(OGS1InterRegionRemoting),
661 "tcp://" + regInfo.RemotingAddress + 661 "tcp://" + regInfo.RemotingAddress +
662 ":" + regInfo.RemotingPort + 662 ":" + regInfo.RemotingPort +
663 "/InterRegions"); 663 "/InterRegions");
664 664
665 if (remObject != null) 665 if (remObject != null)
666 { 666 {
667 // retValue = 667 // retValue =
668 remObject.TellRegionToCloseChildConnection(regionHandle, agentID.Guid); 668 remObject.TellRegionToCloseChildConnection(regionHandle, agentID.Guid);
669 } 669 }
670 else 670 else
671 { 671 {
672 m_log.Warn("[HGrid]: Remoting object not found"); 672 m_log.Warn("[HGrid]: Remoting object not found");
673 } 673 }
674 remObject = null; 674 remObject = null;
675 675
676 return true; 676 return true;
677 } 677 }
678 //TODO need to see if we know about where this region is and use .net remoting 678 //TODO need to see if we know about where this region is and use .net remoting
679 // to inform it. 679 // to inform it.
680 NoteDeadRegion(regionHandle); 680 NoteDeadRegion(regionHandle);
681 return false; 681 return false;
682 } 682 }
683 catch (RemotingException) 683 catch (RemotingException)
684 { 684 {
685 NoteDeadRegion(regionHandle); 685 NoteDeadRegion(regionHandle);
686 m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region to tell it to close child agents: " + regInfo.RegionName + 686 m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region to tell it to close child agents: " + regInfo.RegionName +
687 " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); 687 " " + regInfo.RegionLocX + "," + regInfo.RegionLocY);
688 //m_log.Debug(e.ToString()); 688 //m_log.Debug(e.ToString());
689 return false; 689 return false;
690 } 690 }
691 catch (SocketException e) 691 catch (SocketException e)
692 { 692 {
693 NoteDeadRegion(regionHandle); 693 NoteDeadRegion(regionHandle);
694 m_log.Warn("[HGridS]: Socket Error: Unable to connect to adjacent region using tcp://" + 694 m_log.Warn("[HGridS]: Socket Error: Unable to connect to adjacent region using tcp://" +
695 regInfo.RemotingAddress + 695 regInfo.RemotingAddress +
696 ":" + regInfo.RemotingPort + 696 ":" + regInfo.RemotingPort +
697 "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + 697 "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY +
698 " - Is this neighbor up?"); 698 " - Is this neighbor up?");
699 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 699 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
700 return false; 700 return false;
701 } 701 }
702 catch (InvalidCredentialException e) 702 catch (InvalidCredentialException e)
703 { 703 {
704 NoteDeadRegion(regionHandle); 704 NoteDeadRegion(regionHandle);
705 m_log.Warn("[HGrid]: Invalid Credentials: Unable to connect to adjacent region using tcp://" + 705 m_log.Warn("[HGrid]: Invalid Credentials: Unable to connect to adjacent region using tcp://" +
706 regInfo.RemotingAddress + 706 regInfo.RemotingAddress +
707 ":" + regInfo.RemotingPort + 707 ":" + regInfo.RemotingPort +
708 "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); 708 "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY);
709 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 709 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
710 return false; 710 return false;
711 } 711 }
712 catch (AuthenticationException e) 712 catch (AuthenticationException e)
713 { 713 {
714 NoteDeadRegion(regionHandle); 714 NoteDeadRegion(regionHandle);
715 m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region using tcp://" + 715 m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region using tcp://" +
716 regInfo.RemotingAddress + 716 regInfo.RemotingAddress +
717 ":" + regInfo.RemotingPort + 717 ":" + regInfo.RemotingPort +
718 "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); 718 "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY);
719 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 719 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
720 return false; 720 return false;
721 } 721 }
722 catch (WebException e) 722 catch (WebException e)
723 { 723 {
724 NoteDeadRegion(regionHandle); 724 NoteDeadRegion(regionHandle);
725 m_log.Warn("[HGrid]: WebException exception: Unable to connect to adjacent region using tcp://" + 725 m_log.Warn("[HGrid]: WebException exception: Unable to connect to adjacent region using tcp://" +
726 regInfo.RemotingAddress + 726 regInfo.RemotingAddress +
727 ":" + regInfo.RemotingPort + 727 ":" + regInfo.RemotingPort +
728 "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); 728 "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY);
729 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); 729 m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message);
730 return false; 730 return false;
731 } 731 }
732 catch (Exception e) 732 catch (Exception e)
733 { 733 {
734 NoteDeadRegion(regionHandle); 734 NoteDeadRegion(regionHandle);
735 // This line errors with a Null Reference Exception.. Why? @.@ 735 // This line errors with a Null Reference Exception.. Why? @.@
736 //m_log.Warn("Unknown exception: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + 736 //m_log.Warn("Unknown exception: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress +
737 // ":" + regInfo.RemotingPort + 737 // ":" + regInfo.RemotingPort +
738 //"/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - This is likely caused by an incompatibility in the protocol between this sim and that one"); 738 //"/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - This is likely caused by an incompatibility in the protocol between this sim and that one");
739 m_log.DebugFormat("[HGrid]: {0}", e); 739 m_log.DebugFormat("[HGrid]: {0}", e);
740 return false; 740 return false;
741 } 741 }
742 } 742 }
743 743
744 public override bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId) 744 public override bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId)
745 { 745 {
746 return m_localBackend.AcknowledgeAgentCrossed(regionHandle, agentId); 746 return m_localBackend.AcknowledgeAgentCrossed(regionHandle, agentId);
747 } 747 }
748 748
749 public override bool AcknowledgePrimCrossed(ulong regionHandle, UUID primId) 749 public override bool AcknowledgePrimCrossed(ulong regionHandle, UUID primId)
750 { 750 {
751 return m_localBackend.AcknowledgePrimCrossed(regionHandle, primId); 751 return m_localBackend.AcknowledgePrimCrossed(regionHandle, primId);
752 } 752 }
753 753
754 #endregion 754 #endregion
755 755
756 #region Methods triggered by calls from external instances 756 #region Methods triggered by calls from external instances
757 757
758 /// <summary> 758 /// <summary>
759 /// 759 ///
760 /// </summary> 760 /// </summary>
761 /// <param name="regionHandle"></param> 761 /// <param name="regionHandle"></param>
762 /// <param name="agentData"></param> 762 /// <param name="agentData"></param>
763 /// <returns></returns> 763 /// <returns></returns>
764 public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) 764 public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData)
765 { 765 {
766 HGIncomingChildAgent(regionHandle, agentData); 766 HGIncomingChildAgent(regionHandle, agentData);
767 767
768 m_log.Info("[HGrid]: " + gdebugRegionName + ": Incoming HGrid Agent " + agentData.firstname + " " + agentData.lastname); 768 m_log.Info("[HGrid]: " + gdebugRegionName + ": Incoming HGrid Agent " + agentData.firstname + " " + agentData.lastname);
769 769
770 return m_localBackend.IncomingChildAgent(regionHandle, agentData); 770 return m_localBackend.IncomingChildAgent(regionHandle, agentData);
771 } 771 }
772 772
773 public bool TriggerRegionUp(RegionUpData regionData, ulong regionhandle) 773 public bool TriggerRegionUp(RegionUpData regionData, ulong regionhandle)
774 { 774 {
775 m_log.Info( 775 m_log.Info(
776 "[HGrid]: " + 776 "[HGrid]: " +
777 m_localBackend._gdebugRegionName + "Incoming HGrid RegionUpReport: " + "(" + regionData.X + 777 m_localBackend._gdebugRegionName + "Incoming HGrid RegionUpReport: " + "(" + regionData.X +
778 "," + regionData.Y + "). Giving this region a fresh set of 'dead' tries"); 778 "," + regionData.Y + "). Giving this region a fresh set of 'dead' tries");
779 779
780 RegionInfo nRegionInfo = new RegionInfo(); 780 RegionInfo nRegionInfo = new RegionInfo();
781 nRegionInfo.SetEndPoint("127.0.0.1", regionData.PORT); 781 nRegionInfo.SetEndPoint("127.0.0.1", regionData.PORT);
782 nRegionInfo.ExternalHostName = regionData.IPADDR; 782 nRegionInfo.ExternalHostName = regionData.IPADDR;
783 nRegionInfo.RegionLocX = regionData.X; 783 nRegionInfo.RegionLocX = regionData.X;
784 nRegionInfo.RegionLocY = regionData.Y; 784 nRegionInfo.RegionLocY = regionData.Y;
785 785
786 lock (m_deadRegionCache) 786 lock (m_deadRegionCache)
787 { 787 {
788 if (m_deadRegionCache.ContainsKey(nRegionInfo.RegionHandle)) 788 if (m_deadRegionCache.ContainsKey(nRegionInfo.RegionHandle))
789 { 789 {
790 m_deadRegionCache.Remove(nRegionInfo.RegionHandle); 790 m_deadRegionCache.Remove(nRegionInfo.RegionHandle);
791 } 791 }
792 } 792 }
793 793
794 return m_localBackend.TriggerRegionUp(nRegionInfo, regionhandle); 794 return m_localBackend.TriggerRegionUp(nRegionInfo, regionhandle);
795 } 795 }
796 796
797 public bool TriggerChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) 797 public bool TriggerChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData)
798 { 798 {
799 //m_log.Info("[INTER]: Incoming HGrid Child Agent Data Update"); 799 //m_log.Info("[INTER]: Incoming HGrid Child Agent Data Update");
800 800
801 return m_localBackend.TriggerChildAgentUpdate(regionHandle, cAgentData); 801 return m_localBackend.TriggerChildAgentUpdate(regionHandle, cAgentData);
802 } 802 }
803 803
804 /// <summary> 804 /// <summary>
805 /// 805 ///
806 /// </summary> 806 /// </summary>
807 /// <param name="regionHandle"></param> 807 /// <param name="regionHandle"></param>
808 /// <param name="agentData"></param> 808 /// <param name="agentData"></param>
809 /// <returns></returns> 809 /// <returns></returns>
810 public bool IncomingPrim(ulong regionHandle, UUID primID, string objData, int XMLMethod) 810 public bool IncomingPrim(ulong regionHandle, UUID primID, string objData, int XMLMethod)
811 { 811 {
812 m_localBackend.TriggerExpectPrim(regionHandle, primID, objData, XMLMethod); 812 m_localBackend.TriggerExpectPrim(regionHandle, primID, objData, XMLMethod);
813 813
814 return true; 814 return true;
815 } 815 }
816 816
817 /// <summary> 817 /// <summary>
818 /// 818 ///
819 /// </summary> 819 /// </summary>
820 /// <param name="regionHandle"></param> 820 /// <param name="regionHandle"></param>
821 /// <param name="agentID"></param> 821 /// <param name="agentID"></param>
822 /// <param name="position"></param> 822 /// <param name="position"></param>
823 /// <returns></returns> 823 /// <returns></returns>
824 public bool TriggerExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) 824 public bool TriggerExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying)
825 { 825 {
826 return m_localBackend.TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); 826 return m_localBackend.TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying);
827 } 827 }
828 828
829 public bool TriggerExpectPrimCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isPhysical) 829 public bool TriggerExpectPrimCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isPhysical)
830 { 830 {
831 return m_localBackend.TriggerExpectPrimCrossing(regionHandle, agentID, position, isPhysical); 831 return m_localBackend.TriggerExpectPrimCrossing(regionHandle, agentID, position, isPhysical);
832 } 832 }
833 833
834 public bool TriggerTellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) 834 public bool TriggerTellRegionToCloseChildConnection(ulong regionHandle, UUID agentID)
835 { 835 {
836 return m_localBackend.TriggerTellRegionToCloseChildConnection(regionHandle, agentID); 836 return m_localBackend.TriggerTellRegionToCloseChildConnection(regionHandle, agentID);
837 } 837 }
838 838
839 int timeOut = 10; //10 seconds 839 int timeOut = 10; //10 seconds
840 /// <summary> 840 /// <summary>
841 /// Check that a region is available for TCP comms. This is necessary for .NET remoting between regions. 841 /// Check that a region is available for TCP comms. This is necessary for .NET remoting between regions.
842 /// </summary> 842 /// </summary>
843 /// <param name="address"></param> 843 /// <param name="address"></param>
844 /// <param name="port"></param> 844 /// <param name="port"></param>
845 /// <param name="retry"></param> 845 /// <param name="retry"></param>
846 /// <returns></returns> 846 /// <returns></returns>
847 public bool CheckRegion(string address, uint port, bool retry) 847 public bool CheckRegion(string address, uint port, bool retry)
848 { 848 {
849 bool available = false; 849 bool available = false;
850 bool timed_out = true; 850 bool timed_out = true;
851 851
852 IPAddress ia; 852 IPAddress ia;
853 IPAddress.TryParse(address, out ia); 853 IPAddress.TryParse(address, out ia);
854 IPEndPoint m_EndPoint = new IPEndPoint(ia, (int)port); 854 IPEndPoint m_EndPoint = new IPEndPoint(ia, (int)port);
855 855
856 AsyncCallback callback = delegate(IAsyncResult iar) 856 AsyncCallback callback = delegate(IAsyncResult iar)
857 { 857 {
858 Socket s = (Socket)iar.AsyncState; 858 Socket s = (Socket)iar.AsyncState;
859 try 859 try
860 { 860 {
861 s.EndConnect(iar); 861 s.EndConnect(iar);
862 available = true; 862 available = true;
863 timed_out = false; 863 timed_out = false;
864 } 864 }
865 catch (Exception e) 865 catch (Exception e)
866 { 866 {
867 m_log.DebugFormat( 867 m_log.DebugFormat(
868 "[HGrid]: Callback EndConnect exception: {0}:{1}", e.Message, e.StackTrace); 868 "[HGrid]: Callback EndConnect exception: {0}:{1}", e.Message, e.StackTrace);
869 } 869 }
870 870
871 s.Close(); 871 s.Close();
872 }; 872 };
873 873
874 try 874 try
875 { 875 {
876 Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 876 Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
877 IAsyncResult ar = socket.BeginConnect(m_EndPoint, callback, socket); 877 IAsyncResult ar = socket.BeginConnect(m_EndPoint, callback, socket);
878 ar.AsyncWaitHandle.WaitOne(timeOut * 1000, false); 878 ar.AsyncWaitHandle.WaitOne(timeOut * 1000, false);
879 } 879 }
880 catch (Exception e) 880 catch (Exception e)
881 { 881 {
882 m_log.DebugFormat( 882 m_log.DebugFormat(
883 "[HGrid]: CheckRegion Socket Setup exception: {0}:{1}", e.Message, e.StackTrace); 883 "[HGrid]: CheckRegion Socket Setup exception: {0}:{1}", e.Message, e.StackTrace);
884 884
885 return false; 885 return false;
886 } 886 }
887 887
888 if (timed_out) 888 if (timed_out)
889 { 889 {
890 m_log.DebugFormat( 890 m_log.DebugFormat(
891 "[HGrid]: socket [{0}] timed out ({1}) waiting to obtain a connection.", 891 "[HGrid]: socket [{0}] timed out ({1}) waiting to obtain a connection.",
892 m_EndPoint, timeOut * 1000); 892 m_EndPoint, timeOut * 1000);
893 893
894 if (retry) 894 if (retry)
895 { 895 {
896 return CheckRegion(address, port, false); 896 return CheckRegion(address, port, false);
897 } 897 }
898 } 898 }
899 899
900 return available; 900 return available;
901 } 901 }
902 902
903 public override bool CheckRegion(string address, uint port) 903 public override bool CheckRegion(string address, uint port)
904 { 904 {
905 return CheckRegion(address, port, true); 905 return CheckRegion(address, port, true);
906 } 906 }
907 907
908 public void NoteDeadRegion(ulong regionhandle) 908 public void NoteDeadRegion(ulong regionhandle)
909 { 909 {
910 lock (m_deadRegionCache) 910 lock (m_deadRegionCache)
911 { 911 {
912 if (m_deadRegionCache.ContainsKey(regionhandle)) 912 if (m_deadRegionCache.ContainsKey(regionhandle))
913 { 913 {
914 m_deadRegionCache[regionhandle] = m_deadRegionCache[regionhandle] + 1; 914 m_deadRegionCache[regionhandle] = m_deadRegionCache[regionhandle] + 1;
915 } 915 }
916 else 916 else
917 { 917 {
918 m_deadRegionCache.Add(regionhandle, 1); 918 m_deadRegionCache.Add(regionhandle, 1);
919 } 919 }
920 } 920 }
921 921
922 } 922 }
923 923
924 #endregion 924 #endregion
925 925
926 926
927 } 927 }
928} 928}