aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-04-01 22:37:20 +0100
committerJustin Clark-Casey (justincc)2010-04-01 22:37:20 +0100
commitc33b1de9dfc238ca38a0f145160de2648189dd16 (patch)
treec11d3cd4479aa2e587b97d72244578625261009a /OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups
parentWhen saving an oar/iar, don't attempt to write out the data byte array if it'... (diff)
downloadopensim-SC-c33b1de9dfc238ca38a0f145160de2648189dd16.zip
opensim-SC-c33b1de9dfc238ca38a0f145160de2648189dd16.tar.gz
opensim-SC-c33b1de9dfc238ca38a0f145160de2648189dd16.tar.bz2
opensim-SC-c33b1de9dfc238ca38a0f145160de2648189dd16.tar.xz
expose methods that allow region modules to send messages to groups
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs144
1 files changed, 81 insertions, 63 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
index 00fe5df..e0840b1 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
@@ -28,29 +28,23 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31
32
33using log4net; 31using log4net;
34using Mono.Addins; 32using Mono.Addins;
35using Nini.Config; 33using Nini.Config;
36
37using OpenMetaverse; 34using OpenMetaverse;
38using OpenMetaverse.StructuredData; 35using OpenMetaverse.StructuredData;
39
40using OpenSim.Framework; 36using OpenSim.Framework;
41using OpenSim.Region.CoreModules.Framework.EventQueue; 37using OpenSim.Region.CoreModules.Framework.EventQueue;
42using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
44 40
45
46using Caps = OpenSim.Framework.Capabilities.Caps; 41using Caps = OpenSim.Framework.Capabilities.Caps;
47 42
48namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups 43namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
49{ 44{
50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
51 public class GroupsMessagingModule : ISharedRegionModule 46 public class GroupsMessagingModule : ISharedRegionModule, IGroupsMessagingModule
52 { 47 {
53
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 49
56 private List<Scene> m_sceneList = new List<Scene>(); 50 private List<Scene> m_sceneList = new List<Scene>();
@@ -108,8 +102,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
108 102
109 public void AddRegion(Scene scene) 103 public void AddRegion(Scene scene)
110 { 104 {
111 // NoOp 105 if (!m_groupMessagingEnabled)
106 return;
107
108 scene.RegisterModuleInterface<IGroupsMessagingModule>(this);
112 } 109 }
110
113 public void RegionLoaded(Scene scene) 111 public void RegionLoaded(Scene scene)
114 { 112 {
115 if (!m_groupMessagingEnabled) 113 if (!m_groupMessagingEnabled)
@@ -197,6 +195,75 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
197 195
198 #endregion 196 #endregion
199 197
198 public bool StartGroupChatSession(UUID agentID, UUID groupID)
199 {
200 if (m_debugEnabled)
201 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
202
203 GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID);
204
205 if (groupInfo != null)
206 return StartGroupChatSession(agentID.Guid, groupInfo);
207 else
208 return false;
209 }
210
211 protected bool StartGroupChatSession(Guid agentID, GroupRecord groupInfo)
212 {
213 AddAgentToGroupSession(agentID, groupInfo.GroupID.Guid);
214
215 return true;
216 }
217
218 public void SendMessageToGroup(GridInstantMessage im, UUID groupID)
219 {
220 if (m_debugEnabled)
221 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
222
223 foreach (GroupMembersData member in m_groupsModule.GroupMembersRequest(null, groupID))
224 {
225 if (!m_agentsDroppedSession.ContainsKey(im.imSessionID) || m_agentsDroppedSession[im.imSessionID].Contains(member.AgentID.Guid))
226 {
227 // Don't deliver messages to people who have dropped this session
228 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID);
229 continue;
230 }
231
232 // Copy Message
233 GridInstantMessage msg = new GridInstantMessage();
234 msg.imSessionID = im.imSessionID;
235 msg.fromAgentName = im.fromAgentName;
236 msg.message = im.message;
237 msg.dialog = im.dialog;
238 msg.offline = im.offline;
239 msg.ParentEstateID = im.ParentEstateID;
240 msg.Position = im.Position;
241 msg.RegionID = im.RegionID;
242 msg.binaryBucket = im.binaryBucket;
243 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
244
245 // Updat Pertinate fields to make it a "group message"
246 msg.fromAgentID = groupID.Guid;
247 msg.fromGroup = true;
248
249 msg.toAgentID = member.AgentID.Guid;
250
251 IClientAPI client = GetActiveClient(member.AgentID);
252 if (client == null)
253 {
254 // If they're not local, forward across the grid
255 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID);
256 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
257 }
258 else
259 {
260 // Deliver locally, directly
261 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name);
262 ProcessMessageFromGroupSession(msg);
263 }
264 }
265 }
266
200 #region SimGridEventHandlers 267 #region SimGridEventHandlers
201 268
202 private void OnNewClient(IClientAPI client) 269 private void OnNewClient(IClientAPI client)
@@ -370,7 +437,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
370 m_agentsDroppedSession.Add(sessionID, new List<Guid>()); 437 m_agentsDroppedSession.Add(sessionID, new List<Guid>());
371 } 438 }
372 } 439 }
373 440
374 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 441 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
375 { 442 {
376 if (m_debugEnabled) 443 if (m_debugEnabled)
@@ -384,13 +451,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
384 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) 451 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
385 { 452 {
386 UUID groupID = new UUID(im.toAgentID); 453 UUID groupID = new UUID(im.toAgentID);
387
388 GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID); 454 GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID);
455
389 if (groupInfo != null) 456 if (groupInfo != null)
390 { 457 {
391 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Start Group Session for {0}", groupInfo.GroupName); 458 StartGroupChatSession(im.fromAgentID, groupInfo);
392
393 AddAgentToGroupSession(im.fromAgentID, im.imSessionID);
394 459
395 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, groupID); 460 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, groupID);
396 461
@@ -411,7 +476,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
411 { 476 {
412 UUID groupID = new UUID(im.toAgentID); 477 UUID groupID = new UUID(im.toAgentID);
413 478
414 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", groupID, im.imSessionID.ToString()); 479 if (m_debugEnabled)
480 m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", groupID, im.imSessionID.ToString());
415 481
416 SendMessageToGroup(im, groupID); 482 SendMessageToGroup(im, groupID);
417 } 483 }
@@ -419,54 +485,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
419 485
420 #endregion 486 #endregion
421 487
422 private void SendMessageToGroup(GridInstantMessage im, UUID groupID)
423 {
424 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
425
426 foreach (GroupMembersData member in m_groupsModule.GroupMembersRequest(null, groupID))
427 {
428 if (!m_agentsDroppedSession.ContainsKey(im.imSessionID) || m_agentsDroppedSession[im.imSessionID].Contains(member.AgentID.Guid))
429 {
430 // Don't deliver messages to people who have dropped this session
431 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID);
432 continue;
433 }
434
435 // Copy Message
436 GridInstantMessage msg = new GridInstantMessage();
437 msg.imSessionID = im.imSessionID;
438 msg.fromAgentName = im.fromAgentName;
439 msg.message = im.message;
440 msg.dialog = im.dialog;
441 msg.offline = im.offline;
442 msg.ParentEstateID = im.ParentEstateID;
443 msg.Position = im.Position;
444 msg.RegionID = im.RegionID;
445 msg.binaryBucket = im.binaryBucket;
446 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
447
448 // Updat Pertinate fields to make it a "group message"
449 msg.fromAgentID = groupID.Guid;
450 msg.fromGroup = true;
451
452 msg.toAgentID = member.AgentID.Guid;
453
454 IClientAPI client = GetActiveClient(member.AgentID);
455 if (client == null)
456 {
457 // If they're not local, forward across the grid
458 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID);
459 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
460 }
461 else
462 {
463 // Deliver locally, directly
464 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name);
465 ProcessMessageFromGroupSession(msg);
466 }
467 }
468 }
469
470 void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID) 488 void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID)
471 { 489 {
472 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 490 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);