diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | 142 |
1 files changed, 79 insertions, 63 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index 00fe5df..533815f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | |||
@@ -28,29 +28,23 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | |||
32 | |||
33 | using log4net; | 31 | using log4net; |
34 | using Mono.Addins; | 32 | using Mono.Addins; |
35 | using Nini.Config; | 33 | using Nini.Config; |
36 | |||
37 | using OpenMetaverse; | 34 | using OpenMetaverse; |
38 | using OpenMetaverse.StructuredData; | 35 | using OpenMetaverse.StructuredData; |
39 | |||
40 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
41 | using OpenSim.Region.CoreModules.Framework.EventQueue; | 37 | using OpenSim.Region.CoreModules.Framework.EventQueue; |
42 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
44 | 40 | ||
45 | |||
46 | using Caps = OpenSim.Framework.Capabilities.Caps; | 41 | using Caps = OpenSim.Framework.Capabilities.Caps; |
47 | 42 | ||
48 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | 43 | namespace 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,73 @@ 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 | { | ||
207 | AddAgentToGroupSession(agentID.Guid, groupID.Guid); | ||
208 | return true; | ||
209 | } | ||
210 | else | ||
211 | { | ||
212 | return false; | ||
213 | } | ||
214 | } | ||
215 | |||
216 | public void SendMessageToGroup(GridInstantMessage im, UUID groupID) | ||
217 | { | ||
218 | if (m_debugEnabled) | ||
219 | m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | ||
220 | |||
221 | foreach (GroupMembersData member in m_groupsModule.GroupMembersRequest(null, groupID)) | ||
222 | { | ||
223 | if (!m_agentsDroppedSession.ContainsKey(im.imSessionID) || m_agentsDroppedSession[im.imSessionID].Contains(member.AgentID.Guid)) | ||
224 | { | ||
225 | // Don't deliver messages to people who have dropped this session | ||
226 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID); | ||
227 | continue; | ||
228 | } | ||
229 | |||
230 | // Copy Message | ||
231 | GridInstantMessage msg = new GridInstantMessage(); | ||
232 | msg.imSessionID = im.imSessionID; | ||
233 | msg.fromAgentName = im.fromAgentName; | ||
234 | msg.message = im.message; | ||
235 | msg.dialog = im.dialog; | ||
236 | msg.offline = im.offline; | ||
237 | msg.ParentEstateID = im.ParentEstateID; | ||
238 | msg.Position = im.Position; | ||
239 | msg.RegionID = im.RegionID; | ||
240 | msg.binaryBucket = im.binaryBucket; | ||
241 | msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
242 | |||
243 | // Updat Pertinate fields to make it a "group message" | ||
244 | msg.fromAgentID = groupID.Guid; | ||
245 | msg.fromGroup = true; | ||
246 | |||
247 | msg.toAgentID = member.AgentID.Guid; | ||
248 | |||
249 | IClientAPI client = GetActiveClient(member.AgentID); | ||
250 | if (client == null) | ||
251 | { | ||
252 | // If they're not local, forward across the grid | ||
253 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID); | ||
254 | m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); | ||
255 | } | ||
256 | else | ||
257 | { | ||
258 | // Deliver locally, directly | ||
259 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name); | ||
260 | ProcessMessageFromGroupSession(msg); | ||
261 | } | ||
262 | } | ||
263 | } | ||
264 | |||
200 | #region SimGridEventHandlers | 265 | #region SimGridEventHandlers |
201 | 266 | ||
202 | private void OnNewClient(IClientAPI client) | 267 | private void OnNewClient(IClientAPI client) |
@@ -370,7 +435,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
370 | m_agentsDroppedSession.Add(sessionID, new List<Guid>()); | 435 | m_agentsDroppedSession.Add(sessionID, new List<Guid>()); |
371 | } | 436 | } |
372 | } | 437 | } |
373 | 438 | ||
374 | private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) | 439 | private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) |
375 | { | 440 | { |
376 | if (m_debugEnabled) | 441 | if (m_debugEnabled) |
@@ -384,13 +449,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
384 | if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) | 449 | if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) |
385 | { | 450 | { |
386 | UUID groupID = new UUID(im.toAgentID); | 451 | UUID groupID = new UUID(im.toAgentID); |
387 | |||
388 | GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID); | 452 | GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID); |
453 | |||
389 | if (groupInfo != null) | 454 | if (groupInfo != null) |
390 | { | 455 | { |
391 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Start Group Session for {0}", groupInfo.GroupName); | 456 | AddAgentToGroupSession(im.fromAgentID, groupInfo.GroupID.Guid); |
392 | |||
393 | AddAgentToGroupSession(im.fromAgentID, im.imSessionID); | ||
394 | 457 | ||
395 | ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, groupID); | 458 | ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, groupID); |
396 | 459 | ||
@@ -411,7 +474,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
411 | { | 474 | { |
412 | UUID groupID = new UUID(im.toAgentID); | 475 | UUID groupID = new UUID(im.toAgentID); |
413 | 476 | ||
414 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", groupID, im.imSessionID.ToString()); | 477 | if (m_debugEnabled) |
478 | m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", groupID, im.imSessionID.ToString()); | ||
415 | 479 | ||
416 | SendMessageToGroup(im, groupID); | 480 | SendMessageToGroup(im, groupID); |
417 | } | 481 | } |
@@ -419,54 +483,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
419 | 483 | ||
420 | #endregion | 484 | #endregion |
421 | 485 | ||
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) | 486 | void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID) |
471 | { | 487 | { |
472 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 488 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |