aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Chat
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Chat')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs293
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs67
2 files changed, 236 insertions, 124 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index f0b1e67..ea90185 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -45,17 +45,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
45 private static readonly ILog m_log = 45 private static readonly ILog m_log =
46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 private const int DEBUG_CHANNEL = 2147483647; 48 protected const int DEBUG_CHANNEL = 2147483647;
49 49
50 private bool m_enabled = true; 50 protected bool m_enabled = true;
51 private int m_saydistance = 20; 51 protected int m_saydistance = 20;
52 private int m_shoutdistance = 100; 52 protected int m_shoutdistance = 100;
53 private int m_whisperdistance = 10; 53 protected int m_whisperdistance = 10;
54 54 protected List<Scene> m_scenes = new List<Scene>();
55 internal object m_syncy = new object(); 55 protected List<string> FreezeCache = new List<string>();
56 56 protected string m_adminPrefix = "";
57 internal IConfig m_config; 57 protected object m_syncy = new object();
58 58 protected IConfig m_config;
59 #region ISharedRegionModule Members 59 #region ISharedRegionModule Members
60 public virtual void Initialise(IConfigSource config) 60 public virtual void Initialise(IConfigSource config)
61 { 61 {
@@ -69,21 +69,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
69 m_enabled = false; 69 m_enabled = false;
70 return; 70 return;
71 } 71 }
72 }
73 72
74 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); 73 m_whisperdistance = m_config.GetInt("whisper_distance", m_whisperdistance);
75 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); 74 m_saydistance = m_config.GetInt("say_distance", m_saydistance);
76 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); 75 m_shoutdistance = m_config.GetInt("shout_distance", m_shoutdistance);
76 m_adminPrefix = m_config.GetString("admin_prefix", "");
77 }
77 } 78 }
78 79
79 public virtual void AddRegion(Scene scene) 80 public virtual void AddRegion(Scene scene)
80 { 81 {
81 if (!m_enabled) 82 if (!m_enabled) return;
82 return;
83 83
84 scene.EventManager.OnNewClient += OnNewClient; 84 lock (m_syncy)
85 scene.EventManager.OnChatFromWorld += OnChatFromWorld; 85 {
86 scene.EventManager.OnChatBroadcast += OnChatBroadcast; 86 if (!m_scenes.Contains(scene))
87 {
88 m_scenes.Add(scene);
89 scene.EventManager.OnNewClient += OnNewClient;
90 scene.EventManager.OnChatFromWorld += OnChatFromWorld;
91 scene.EventManager.OnChatBroadcast += OnChatBroadcast;
92 }
93 }
87 94
88 m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName, 95 m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName,
89 m_whisperdistance, m_saydistance, m_shoutdistance); 96 m_whisperdistance, m_saydistance, m_shoutdistance);
@@ -103,14 +110,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
103 110
104 public virtual void RemoveRegion(Scene scene) 111 public virtual void RemoveRegion(Scene scene)
105 { 112 {
106 if (!m_enabled) 113 if (!m_enabled) return;
107 return;
108 114
109 scene.EventManager.OnNewClient -= OnNewClient; 115 lock (m_syncy)
110 scene.EventManager.OnChatFromWorld -= OnChatFromWorld; 116 {
111 scene.EventManager.OnChatBroadcast -= OnChatBroadcast; 117 if (m_scenes.Contains(scene))
118 {
119 scene.EventManager.OnNewClient -= OnNewClient;
120 scene.EventManager.OnChatFromWorld -= OnChatFromWorld;
121 scene.EventManager.OnChatBroadcast -= OnChatBroadcast;
122 m_scenes.Remove(scene);
123 }
124 }
112 } 125 }
113 126
114 public virtual void Close() 127 public virtual void Close()
115 { 128 {
116 } 129 }
@@ -119,7 +132,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
119 { 132 {
120 } 133 }
121 134
122 public Type ReplaceableInterface 135 public virtual Type ReplaceableInterface
123 { 136 {
124 get { return null; } 137 get { return null; }
125 } 138 }
@@ -137,7 +150,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
137 client.OnChatFromClient += OnChatFromClient; 150 client.OnChatFromClient += OnChatFromClient;
138 } 151 }
139 152
140 protected OSChatMessage FixPositionOfChatMessage(OSChatMessage c) 153 protected virtual OSChatMessage FixPositionOfChatMessage(OSChatMessage c)
141 { 154 {
142 ScenePresence avatar; 155 ScenePresence avatar;
143 Scene scene = (Scene)c.Scene; 156 Scene scene = (Scene)c.Scene;
@@ -165,7 +178,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
165 return; 178 return;
166 } 179 }
167 180
168 DeliverChatToAvatars(ChatSourceType.Agent, c); 181 if (FreezeCache.Contains(c.Sender.AgentId.ToString()))
182 {
183 if (c.Type != ChatTypeEnum.StartTyping || c.Type != ChatTypeEnum.StopTyping)
184 c.Sender.SendAgentAlertMessage("You may not talk as you are frozen.", false);
185 }
186 else
187 {
188 DeliverChatToAvatars(ChatSourceType.Agent, c);
189 }
169 } 190 }
170 191
171 public virtual void OnChatFromWorld(Object sender, OSChatMessage c) 192 public virtual void OnChatFromWorld(Object sender, OSChatMessage c)
@@ -179,34 +200,63 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
179 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) 200 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
180 { 201 {
181 string fromName = c.From; 202 string fromName = c.From;
203 string fromNamePrefix = "";
182 UUID fromID = UUID.Zero; 204 UUID fromID = UUID.Zero;
183 UUID ownerID = UUID.Zero; 205 UUID ownerID = UUID.Zero;
184 UUID targetID = c.TargetUUID;
185 string message = c.Message; 206 string message = c.Message;
186 Scene scene = (Scene)c.Scene; 207 Scene scene = c.Scene as Scene;
208 UUID destination = c.Destination;
187 Vector3 fromPos = c.Position; 209 Vector3 fromPos = c.Position;
188 Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0); 210 Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0);
189 211
212 bool checkParcelHide = false;
213 UUID sourceParcelID = UUID.Zero;
214 Vector3 hidePos = fromPos;
215
190 if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel; 216 if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel;
191 217
192 switch (sourceType) 218 if(!m_scenes.Contains(scene))
193 { 219 {
194 case ChatSourceType.Agent: 220 m_log.WarnFormat("[CHAT]: message from unkown scene {0} ignored",
195 ScenePresence avatar = scene.GetScenePresence(c.Sender.AgentId); 221 scene.RegionInfo.RegionName);
196 fromPos = avatar.AbsolutePosition; 222 return;
197 fromName = avatar.Name; 223 }
198 fromID = c.Sender.AgentId;
199 ownerID = c.Sender.AgentId;
200 224
201 break; 225 switch (sourceType)
226 {
227 case ChatSourceType.Agent:
228 ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId);
229 fromPos = avatar.AbsolutePosition;
230 fromName = avatar.Name;
231 fromID = c.Sender.AgentId;
232 if (avatar.IsViewerUIGod)
233 { // let gods speak to outside or things may get confusing
234 fromNamePrefix = m_adminPrefix;
235 checkParcelHide = false;
236 }
237 else
238 {
239 checkParcelHide = true;
240 }
241 destination = UUID.Zero; // Avatars cant "SayTo"
242 ownerID = c.Sender.AgentId;
202 243
203 case ChatSourceType.Object: 244 hidePos = fromPos;
204 fromID = c.SenderUUID; 245 break;
205 246
206 if (c.SenderObject != null && c.SenderObject is SceneObjectPart) 247 case ChatSourceType.Object:
207 ownerID = ((SceneObjectPart)c.SenderObject).OwnerID; 248 fromID = c.SenderUUID;
208 249
209 break; 250 if (c.SenderObject != null && c.SenderObject is SceneObjectPart)
251 {
252 ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
253 if (((SceneObjectPart)c.SenderObject).ParentGroup.IsAttachment)
254 {
255 checkParcelHide = true;
256 hidePos = ((SceneObjectPart)c.SenderObject).ParentGroup.AbsolutePosition;
257 }
258 }
259 break;
210 } 260 }
211 261
212 // TODO: iterate over message 262 // TODO: iterate over message
@@ -214,43 +264,66 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
214 message = message.Substring(0, 1000); 264 message = message.Substring(0, 1000);
215 265
216// m_log.DebugFormat( 266// m_log.DebugFormat(
217// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}", 267// "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}",
218// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID); 268// fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType);
219 269
220 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 270 HashSet<UUID> receiverIDs = new HashSet<UUID>();
221 271
222 if (targetID == UUID.Zero) 272 if (checkParcelHide)
223 { 273 {
224 // This should use ForEachClient, but clients don't have a position. 274 checkParcelHide = false;
225 // If camera is moved into client, then camera position can be used 275 if (c.Type < ChatTypeEnum.DebugChannel && destination == UUID.Zero)
226 scene.ForEachScenePresence( 276 {
227 delegate(ScenePresence presence) 277 ILandObject srcland = scene.LandChannel.GetLandObject(hidePos.X, hidePos.Y);
278 if (srcland != null && !srcland.LandData.SeeAVs)
228 { 279 {
229 if (TrySendChatMessage( 280 sourceParcelID = srcland.LandData.GlobalID;
230 presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false)) 281 checkParcelHide = true;
231 receiverIDs.Add(presence.UUID);
232 } 282 }
233 );
234 }
235 else
236 {
237 // This is a send to a specific client eg from llRegionSayTo
238 // no need to check distance etc, jand send is as say
239 ScenePresence presence = scene.GetScenePresence(targetID);
240 if (presence != null && !presence.IsChildAgent)
241 {
242 if (TrySendChatMessage(
243 presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true))
244 receiverIDs.Add(presence.UUID);
245 } 283 }
246 } 284 }
247 285
286 scene.ForEachScenePresence(
287 delegate(ScenePresence presence)
288 {
289 if (destination != UUID.Zero && presence.UUID != destination)
290 return;
291
292 if(presence.IsChildAgent)
293 {
294 if(checkParcelHide)
295 return;
296 if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
297 ownerID, fromNamePrefix + fromName, c.Type,
298 message, sourceType, (destination != UUID.Zero)))
299 receiverIDs.Add(presence.UUID);
300 return;
301 }
302
303 ILandObject Presencecheck = scene.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
304 if (Presencecheck != null)
305 {
306 if (checkParcelHide)
307 {
308 if (sourceParcelID != Presencecheck.LandData.GlobalID && !presence.IsViewerUIGod)
309 return;
310 }
311 if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
312 {
313 if (TrySendChatMessage(presence, fromPos, regionPos, fromID,
314 ownerID, fromNamePrefix + fromName, c.Type,
315 message, sourceType, (destination != UUID.Zero)))
316 receiverIDs.Add(presence.UUID);
317 }
318 }
319 });
320
248 scene.EventManager.TriggerOnChatToClients( 321 scene.EventManager.TriggerOnChatToClients(
249 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); 322 fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
250 } 323 }
251 324
252 static private Vector3 CenterOfRegion = new Vector3(128, 128, 30); 325 static protected Vector3 CenterOfRegion = new Vector3(128, 128, 30);
253 326
254 public virtual void OnChatBroadcast(Object sender, OSChatMessage c) 327 public virtual void OnChatBroadcast(Object sender, OSChatMessage c)
255 { 328 {
256 if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return; 329 if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return;
@@ -268,7 +341,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
268 // broadcast chat works by redistributing every incoming chat 341 // broadcast chat works by redistributing every incoming chat
269 // message to each avatar in the scene. 342 // message to each avatar in the scene.
270 string fromName = c.From; 343 string fromName = c.From;
271 344
272 UUID fromID = UUID.Zero; 345 UUID fromID = UUID.Zero;
273 UUID ownerID = UUID.Zero; 346 UUID ownerID = UUID.Zero;
274 ChatSourceType sourceType = ChatSourceType.Object; 347 ChatSourceType sourceType = ChatSourceType.Object;
@@ -280,35 +353,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
280 ownerID = c.Sender.AgentId; 353 ownerID = c.Sender.AgentId;
281 sourceType = ChatSourceType.Agent; 354 sourceType = ChatSourceType.Agent;
282 } 355 }
283 else if (c.SenderUUID != UUID.Zero) 356 else if (c.SenderUUID != UUID.Zero)
284 { 357 {
285 fromID = c.SenderUUID; 358 fromID = c.SenderUUID;
286 ownerID = ((SceneObjectPart)c.SenderObject).OwnerID; 359 ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
287 } 360 }
288
289 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
290 361
362 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
291 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 363 HashSet<UUID> receiverIDs = new HashSet<UUID>();
292
293 ((Scene)c.Scene).ForEachRootClient(
294 delegate(IClientAPI client)
295 {
296 // don't forward SayOwner chat from objects to
297 // non-owner agents
298 if ((c.Type == ChatTypeEnum.Owner) &&
299 (null != c.SenderObject) &&
300 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
301 return;
302 364
303 client.SendChatMessage( 365 if (c.Scene != null)
304 c.Message, (byte)cType, CenterOfRegion, fromName, fromID, ownerID, 366 {
305 (byte)sourceType, (byte)ChatAudibleLevel.Fully); 367 ((Scene)c.Scene).ForEachRootClient
306 368 (
307 receiverIDs.Add(client.AgentId); 369 delegate(IClientAPI client)
308 }); 370 {
309 371 // don't forward SayOwner chat from objects to
310 (c.Scene as Scene).EventManager.TriggerOnChatToClients( 372 // non-owner agents
311 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); 373 if ((c.Type == ChatTypeEnum.Owner) &&
374 (null != c.SenderObject) &&
375 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
376 return;
377
378 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID,
379 (byte)sourceType, (byte)ChatAudibleLevel.Fully);
380 receiverIDs.Add(client.AgentId);
381 }
382 );
383 (c.Scene as Scene).EventManager.TriggerOnChatToClients(
384 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully);
385 }
312 } 386 }
313 387
314 /// <summary> 388 /// <summary>
@@ -326,7 +400,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
326 /// <param name="type"></param> 400 /// <param name="type"></param>
327 /// <param name="message"></param> 401 /// <param name="message"></param>
328 /// <param name="src"></param> 402 /// <param name="src"></param>
329 /// <returns>true if the message was sent to the receiver, false if it was not sent due to failing a 403 /// <returns>true if the message was sent to the receiver, false if it was not sent due to failing a
330 /// precondition</returns> 404 /// precondition</returns>
331 protected virtual bool TrySendChatMessage( 405 protected virtual bool TrySendChatMessage(
332 ScenePresence presence, Vector3 fromPos, Vector3 regionPos, 406 ScenePresence presence, Vector3 fromPos, Vector3 regionPos,
@@ -356,15 +430,44 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
356 presence.ControllingClient.SendChatMessage( 430 presence.ControllingClient.SendChatMessage(
357 message, (byte) type, fromPos, fromName, 431 message, (byte) type, fromPos, fromName,
358 fromAgentID, ownerID, (byte)src, (byte)ChatAudibleLevel.Fully); 432 fromAgentID, ownerID, (byte)src, (byte)ChatAudibleLevel.Fully);
359 433
360 return true; 434 return true;
361 } 435 }
362 436
437 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
438 public virtual void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
439 {
440 System.Threading.Timer Timer;
441 if (flags == 0)
442 {
443 FreezeCache.Add(target.ToString());
444 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
445 Timer = new System.Threading.Timer(timeCB, target, 30000, 0);
446 Timers.Add(target, Timer);
447 }
448 else
449 {
450 FreezeCache.Remove(target.ToString());
451 Timers.TryGetValue(target, out Timer);
452 Timers.Remove(target);
453 Timer.Dispose();
454 }
455 }
456
457 protected virtual void OnEndParcelFrozen(object avatar)
458 {
459 UUID target = (UUID)avatar;
460 FreezeCache.Remove(target.ToString());
461 System.Threading.Timer Timer;
462 Timers.TryGetValue(target, out Timer);
463 Timers.Remove(target);
464 Timer.Dispose();
465 }
363 #region SimulatorFeaturesRequest 466 #region SimulatorFeaturesRequest
364 467
365 static OSDInteger m_SayRange, m_WhisperRange, m_ShoutRange; 468 protected static OSDInteger m_SayRange, m_WhisperRange, m_ShoutRange;
366 469
367 private void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features) 470 protected virtual void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features)
368 { 471 {
369 OSD extras = new OSDMap(); 472 OSD extras = new OSDMap();
370 if (features.ContainsKey("OpenSimExtras")) 473 if (features.ContainsKey("OpenSimExtras"))
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs
index 3018d94..5457dc3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/Tests/ChatModuleTests.cs
@@ -41,12 +41,13 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
43using OpenSim.Tests.Common; 43using OpenSim.Tests.Common;
44using System.Threading;
44 45
45namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests 46namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
46{ 47{
47 [TestFixture] 48 [TestFixture]
48 public class ChatModuleTests : OpenSimTestCase 49 public class ChatModuleTests : OpenSimTestCase
49 { 50 {
50 [TestFixtureSetUp] 51 [TestFixtureSetUp]
51 public void FixtureInit() 52 public void FixtureInit()
52 { 53 {
@@ -65,14 +66,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
65 } 66 }
66 67
67 private void SetupNeighbourRegions(TestScene sceneA, TestScene sceneB) 68 private void SetupNeighbourRegions(TestScene sceneA, TestScene sceneB)
68 { 69 {
69 // XXX: HTTP server is not (and should not be) necessary for this test, though it's absence makes the 70 // XXX: HTTP server is not (and should not be) necessary for this test, though it's absence makes the
70 // CapabilitiesModule complain when it can't set up HTTP endpoints. 71 // CapabilitiesModule complain when it can't set up HTTP endpoints.
71 // BaseHttpServer httpServer = new BaseHttpServer(99999); 72 BaseHttpServer httpServer = new BaseHttpServer(99999);
72 // MainServer.AddHttpServer(httpServer); 73 MainServer.AddHttpServer(httpServer);
73 // MainServer.Instance = httpServer; 74 MainServer.Instance = httpServer;
74 75
75 // We need entity transfer modules so that when sp2 logs into the east region, the region calls 76 // We need entity transfer modules so that when sp2 logs into the east region, the region calls
76 // EntityTransferModuleto set up a child agent on the west region. 77 // EntityTransferModuleto set up a child agent on the west region.
77 // XXX: However, this is not an entity transfer so is misleading. 78 // XXX: However, this is not an entity transfer so is misleading.
78 EntityTransferModule etmA = new EntityTransferModule(); 79 EntityTransferModule etmA = new EntityTransferModule();
@@ -86,7 +87,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
86 modulesConfig.Set("SimulationServices", lscm.Name); 87 modulesConfig.Set("SimulationServices", lscm.Name);
87 88
88 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); 89 SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
89 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, new ChatModule()); 90 SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, new ChatModule());
90 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB, new ChatModule()); 91 SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB, new ChatModule());
91 } 92 }
92 93
@@ -110,8 +111,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
110 Vector3 sp2Position = new Vector3(250, 128, 20); 111 Vector3 sp2Position = new Vector3(250, 128, 20);
111 112
112 SceneHelpers sh = new SceneHelpers(); 113 SceneHelpers sh = new SceneHelpers();
113 TestScene sceneWest = sh.SetupScene("sceneWest", TestHelpers.ParseTail(0x1), 1000, 1000); 114 TestScene sceneWest = sh.SetupScene("sceneWest", TestHelpers.ParseTail(0x1), 1000, 1000);
114 TestScene sceneEast = sh.SetupScene("sceneEast", TestHelpers.ParseTail(0x2), 1001, 1000); 115 TestScene sceneEast = sh.SetupScene("sceneEast", TestHelpers.ParseTail(0x2), 1001, 1000);
115 116
116 SetupNeighbourRegions(sceneWest, sceneEast); 117 SetupNeighbourRegions(sceneWest, sceneEast);
117 118
@@ -123,12 +124,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
123 // physics is irrelevant to this test. 124 // physics is irrelevant to this test.
124 sp1.Flying = true; 125 sp1.Flying = true;
125 126
126 // When sp1 logs in to sceneEast, it sets up a child agent in sceneWest and informs the sp2 client to 127 // When sp1 logs in to sceneEast, it sets up a child agent in sceneWest and informs the sp2 client to
127 // make the connection. For this test, will simplify this chain by making the connection directly. 128 // make the connection. For this test, will simplify this chain by making the connection directly.
128 ScenePresence sp1Child = SceneHelpers.AddChildScenePresence(sceneWest, sp1Uuid); 129 ScenePresence sp1Child = SceneHelpers.AddChildScenePresence(sceneWest, sp1Uuid);
129 TestClient sp1ChildClient = (TestClient)sp1Child.ControllingClient; 130 TestClient sp1ChildClient = (TestClient)sp1Child.ControllingClient;
130 131
131 sp1.AbsolutePosition = sp1Position; 132 sp1.AbsolutePosition = sp1Position;
132 133
133 ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneWest, sp2Uuid); 134 ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneWest, sp2Uuid);
134 TestClient sp2Client = (TestClient)sp2.ControllingClient; 135 TestClient sp2Client = (TestClient)sp2.ControllingClient;
@@ -137,7 +138,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
137 ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneEast, sp2Uuid); 138 ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneEast, sp2Uuid);
138 TestClient sp2ChildClient = (TestClient)sp2Child.ControllingClient; 139 TestClient sp2ChildClient = (TestClient)sp2Child.ControllingClient;
139 140
140 sp2.AbsolutePosition = sp2Position; 141 sp2.AbsolutePosition = sp2Position;
141 142
142 // We must update the scenes in order to make the root new root agents trigger position updates in their 143 // We must update the scenes in order to make the root new root agents trigger position updates in their
143 // children. 144 // children.
@@ -146,19 +147,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
146 147
147 // Check child positions are correct. 148 // Check child positions are correct.
148 Assert.AreEqual( 149 Assert.AreEqual(
149 new Vector3(sp1Position.X + sceneEast.RegionInfo.RegionSizeX, sp1Position.Y, sp1Position.Z), 150 new Vector3(sp1Position.X + sceneEast.RegionInfo.RegionSizeX, sp1Position.Y, sp1Position.Z),
150 sp1ChildClient.SceneAgent.AbsolutePosition); 151 sp1ChildClient.SceneAgent.AbsolutePosition);
151 152
152 Assert.AreEqual( 153 Assert.AreEqual(
153 new Vector3(sp2Position.X - sceneWest.RegionInfo.RegionSizeX, sp2Position.Y, sp2Position.Z), 154 new Vector3(sp2Position.X - sceneWest.RegionInfo.RegionSizeX, sp2Position.Y, sp2Position.Z),
154 sp2ChildClient.SceneAgent.AbsolutePosition); 155 sp2ChildClient.SceneAgent.AbsolutePosition);
155 156
156 string receivedSp1ChatMessage = ""; 157 string receivedSp1ChatMessage = "";
157 string receivedSp2ChatMessage = ""; 158 string receivedSp2ChatMessage = "";
158 159
159 sp1ChildClient.OnReceivedChatMessage 160 sp1ChildClient.OnReceivedChatMessage
160 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp1ChatMessage = message; 161 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp1ChatMessage = message;
161 sp2ChildClient.OnReceivedChatMessage 162 sp2ChildClient.OnReceivedChatMessage
162 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message; 163 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message;
163 164
164 TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage); 165 TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage);
@@ -166,11 +167,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
166 167
167 sp1Position = new Vector3(30, 128, 20); 168 sp1Position = new Vector3(30, 128, 20);
168 sp1.AbsolutePosition = sp1Position; 169 sp1.AbsolutePosition = sp1Position;
170 sceneWest.Update(1);
169 sceneEast.Update(1); 171 sceneEast.Update(1);
172 Thread.Sleep(12000); // child updates are now time limited
173 sceneWest.Update(5);
174 sceneEast.Update(5);
170 175
171 // Check child position is correct. 176 // Check child position is correct.
172 Assert.AreEqual( 177 Assert.AreEqual(
173 new Vector3(sp1Position.X + sceneEast.RegionInfo.RegionSizeX, sp1Position.Y, sp1Position.Z), 178 new Vector3(sp1Position.X + sceneEast.RegionInfo.RegionSizeX, sp1Position.Y, sp1Position.Z),
174 sp1ChildClient.SceneAgent.AbsolutePosition); 179 sp1ChildClient.SceneAgent.AbsolutePosition);
175 180
176 TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage); 181 TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage);
@@ -197,8 +202,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
197 Vector3 sp2Position = new Vector3(128, 6, 20); 202 Vector3 sp2Position = new Vector3(128, 6, 20);
198 203
199 SceneHelpers sh = new SceneHelpers(); 204 SceneHelpers sh = new SceneHelpers();
200 TestScene sceneNorth = sh.SetupScene("sceneNorth", TestHelpers.ParseTail(0x1), 1000, 1000); 205 TestScene sceneNorth = sh.SetupScene("sceneNorth", TestHelpers.ParseTail(0x1), 1000, 1000);
201 TestScene sceneSouth = sh.SetupScene("sceneSouth", TestHelpers.ParseTail(0x2), 1000, 1001); 206 TestScene sceneSouth = sh.SetupScene("sceneSouth", TestHelpers.ParseTail(0x2), 1000, 1001);
202 207
203 SetupNeighbourRegions(sceneNorth, sceneSouth); 208 SetupNeighbourRegions(sceneNorth, sceneSouth);
204 209
@@ -210,12 +215,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
210 // physics is irrelevant to this test. 215 // physics is irrelevant to this test.
211 sp1.Flying = true; 216 sp1.Flying = true;
212 217
213 // When sp1 logs in to sceneEast, it sets up a child agent in sceneNorth and informs the sp2 client to 218 // When sp1 logs in to sceneEast, it sets up a child agent in sceneNorth and informs the sp2 client to
214 // make the connection. For this test, will simplify this chain by making the connection directly. 219 // make the connection. For this test, will simplify this chain by making the connection directly.
215 ScenePresence sp1Child = SceneHelpers.AddChildScenePresence(sceneSouth, sp1Uuid); 220 ScenePresence sp1Child = SceneHelpers.AddChildScenePresence(sceneSouth, sp1Uuid);
216 TestClient sp1ChildClient = (TestClient)sp1Child.ControllingClient; 221 TestClient sp1ChildClient = (TestClient)sp1Child.ControllingClient;
217 222
218 sp1.AbsolutePosition = sp1Position; 223 sp1.AbsolutePosition = sp1Position;
219 224
220 ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneSouth, sp2Uuid); 225 ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneSouth, sp2Uuid);
221 TestClient sp2Client = (TestClient)sp2.ControllingClient; 226 TestClient sp2Client = (TestClient)sp2.ControllingClient;
@@ -224,7 +229,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
224 ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneNorth, sp2Uuid); 229 ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneNorth, sp2Uuid);
225 TestClient sp2ChildClient = (TestClient)sp2Child.ControllingClient; 230 TestClient sp2ChildClient = (TestClient)sp2Child.ControllingClient;
226 231
227 sp2.AbsolutePosition = sp2Position; 232 sp2.AbsolutePosition = sp2Position;
228 233
229 // We must update the scenes in order to make the root new root agents trigger position updates in their 234 // We must update the scenes in order to make the root new root agents trigger position updates in their
230 // children. 235 // children.
@@ -233,19 +238,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
233 238
234 // Check child positions are correct. 239 // Check child positions are correct.
235 Assert.AreEqual( 240 Assert.AreEqual(
236 new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z), 241 new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z),
237 sp1ChildClient.SceneAgent.AbsolutePosition); 242 sp1ChildClient.SceneAgent.AbsolutePosition);
238 243
239 Assert.AreEqual( 244 Assert.AreEqual(
240 new Vector3(sp2Position.X, sp2Position.Y + sceneSouth.RegionInfo.RegionSizeY, sp2Position.Z), 245 new Vector3(sp2Position.X, sp2Position.Y + sceneSouth.RegionInfo.RegionSizeY, sp2Position.Z),
241 sp2ChildClient.SceneAgent.AbsolutePosition); 246 sp2ChildClient.SceneAgent.AbsolutePosition);
242 247
243 string receivedSp1ChatMessage = ""; 248 string receivedSp1ChatMessage = "";
244 string receivedSp2ChatMessage = ""; 249 string receivedSp2ChatMessage = "";
245 250
246 sp1ChildClient.OnReceivedChatMessage 251 sp1ChildClient.OnReceivedChatMessage
247 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp1ChatMessage = message; 252 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp1ChatMessage = message;
248 sp2ChildClient.OnReceivedChatMessage 253 sp2ChildClient.OnReceivedChatMessage
249 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message; 254 += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message;
250 255
251 TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage); 256 TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage);
@@ -254,16 +259,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat.Tests
254 sp1Position = new Vector3(30, 128, 20); 259 sp1Position = new Vector3(30, 128, 20);
255 sp1.AbsolutePosition = sp1Position; 260 sp1.AbsolutePosition = sp1Position;
256 sceneNorth.Update(1); 261 sceneNorth.Update(1);
262 sceneSouth.Update(1);
263 Thread.Sleep(12000); // child updates are now time limited
264 sceneNorth.Update(5);
265 sceneSouth.Update(5);
257 266
258 // Check child position is correct. 267 // Check child position is correct.
259 Assert.AreEqual( 268 Assert.AreEqual(
260 new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z), 269 new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z),
261 sp1ChildClient.SceneAgent.AbsolutePosition); 270 sp1ChildClient.SceneAgent.AbsolutePosition);
262 271
263 TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage); 272 TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage);
264 TestUserOutOfRange(sp2Client, "lentils", ref receivedSp1ChatMessage); 273 TestUserOutOfRange(sp2Client, "lentils", ref receivedSp1ChatMessage);
265 } 274 }
266 275
267 private void TestUserInRange(TestClient speakClient, string testMessage, ref string receivedMessage) 276 private void TestUserInRange(TestClient speakClient, string testMessage, ref string receivedMessage)
268 { 277 {
269 receivedMessage = ""; 278 receivedMessage = "";