aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Scripting
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Scripting')
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs71
1 files changed, 29 insertions, 42 deletions
diff --git a/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs
index f8e933d..36add06 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs
@@ -34,6 +34,10 @@ using OpenSim.Framework;
34using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
36 36
37// using log4net;
38// using System.Reflection;
39
40
37/***************************************************** 41/*****************************************************
38 * 42 *
39 * WorldCommModule 43 * WorldCommModule
@@ -83,6 +87,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
83{ 87{
84 public class WorldCommModule : IRegionModule, IWorldComm 88 public class WorldCommModule : IRegionModule, IWorldComm
85 { 89 {
90 // private static readonly ILog m_log =
91 // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
92
86 private ListenerManager m_listenerManager; 93 private ListenerManager m_listenerManager;
87 private Queue m_pending; 94 private Queue m_pending;
88 private Queue m_pendingQ; 95 private Queue m_pendingQ;
@@ -117,6 +124,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
117 m_scene.RegisterModuleInterface<IWorldComm>(this); 124 m_scene.RegisterModuleInterface<IWorldComm>(this);
118 m_listenerManager = new ListenerManager(maxlisteners, maxhandles); 125 m_listenerManager = new ListenerManager(maxlisteners, maxhandles);
119 m_scene.EventManager.OnChatFromClient += DeliverClientMessage; 126 m_scene.EventManager.OnChatFromClient += DeliverClientMessage;
127 m_scene.EventManager.OnChatBroadcast += DeliverClientMessage;
120 m_pendingQ = new Queue(); 128 m_pendingQ = new Queue();
121 m_pending = Queue.Synchronized(m_pendingQ); 129 m_pending = Queue.Synchronized(m_pendingQ);
122 } 130 }
@@ -197,6 +205,22 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
197 m_listenerManager.DeleteListener(itemID); 205 m_listenerManager.DeleteListener(itemID);
198 } 206 }
199 207
208 public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg)
209 {
210 Vector3 position;
211 SceneObjectPart source;
212 ScenePresence avatar;
213
214 if ((source = m_scene.GetSceneObjectPart(id)) != null)
215 position = source.AbsolutePosition;
216 else if ((avatar = m_scene.GetScenePresence(id)) != null)
217 position = avatar.AbsolutePosition;
218 else
219 return;
220
221 DeliverMessage(type, channel, name, id, msg, position);
222 }
223
200 /// <summary> 224 /// <summary>
201 /// This method scans over the objects which registered an interest in listen callbacks. 225 /// This method scans over the objects which registered an interest in listen callbacks.
202 /// For everyone it finds, it checks if it fits the given filter. If it does, then 226 /// For everyone it finds, it checks if it fits the given filter. If it does, then
@@ -210,39 +234,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
210 /// <param name="name">name of sender (object or avatar)</param> 234 /// <param name="name">name of sender (object or avatar)</param>
211 /// <param name="id">key of sender (object or avatar)</param> 235 /// <param name="id">key of sender (object or avatar)</param>
212 /// <param name="msg">msg to sent</param> 236 /// <param name="msg">msg to sent</param>
213 public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg) 237 public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg, Vector3 position)
214 { 238 {
215 SceneObjectPart source = null;
216 ScenePresence avatar = null;
217 Vector3 position;
218
219 source = m_scene.GetSceneObjectPart(id);
220 if (source != null)
221 position = source.AbsolutePosition;
222 else {
223 avatar = m_scene.GetScenePresence(id);
224 if (avatar != null)
225 {
226 position = avatar.AbsolutePosition;
227 }
228 else
229 {
230 // This is potentially problematic, though I don't
231 // see how to take advantage of it, basically a request
232 // to send a message to the region does not have to come
233 // from something in the region (eg a plugin can send it)
234 if (type == ChatTypeEnum.Region)
235 {
236 position = new Vector3(128, 128, 20);
237 }
238 else
239 {
240 // bail out early, given source could not be found
241 return;
242 }
243 }
244 }
245
246 // Determine which listen event filters match the given set of arguments, this results 239 // Determine which listen event filters match the given set of arguments, this results
247 // in a limited set of listeners, each belonging a host. If the host is in range, add them 240 // in a limited set of listeners, each belonging a host. If the host is in range, add them
248 // to the pending queue. 241 // to the pending queue.
@@ -326,11 +319,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
326 319
327 #endregion 320 #endregion
328 321
329 // private void NewClient(IClientAPI client)
330 // {
331 // client.OnChatFromViewer += DeliverClientMessage;
332 // }
333
334 /******************************************************************** 322 /********************************************************************
335 * 323 *
336 * Listener Stuff 324 * Listener Stuff
@@ -339,11 +327,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
339 327
340 private void DeliverClientMessage(Object sender, OSChatMessage e) 328 private void DeliverClientMessage(Object sender, OSChatMessage e)
341 { 329 {
342 DeliverMessage(e.Type, 330 if (null != e.Sender)
343 e.Channel, 331 DeliverMessage(e.Type, e.Channel, e.Sender.Name, e.Sender.AgentId, e.Message, e.Position);
344 e.Sender.Name, 332 else
345 e.Sender.AgentId, 333 DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero, e.Message, e.Position);
346 e.Message);
347 } 334 }
348 335
349 public Object[] GetSerializationData(UUID itemID) 336 public Object[] GetSerializationData(UUID itemID)