aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2010-05-06 16:38:23 +0100
committerMelanie2010-05-06 16:39:21 +0100
commit9ecebcdf13ddb29ae1aeec0d080371b7d0696e4d (patch)
tree493f65ded0fe90572497afc2d90dad052f2b8ba2 /OpenSim
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC_OLD-9ecebcdf13ddb29ae1aeec0d080371b7d0696e4d.zip
opensim-SC_OLD-9ecebcdf13ddb29ae1aeec0d080371b7d0696e4d.tar.gz
opensim-SC_OLD-9ecebcdf13ddb29ae1aeec0d080371b7d0696e4d.tar.bz2
opensim-SC_OLD-9ecebcdf13ddb29ae1aeec0d080371b7d0696e4d.tar.xz
Revert "Patch from mcortez: Update groups, add ALPHA Siman grid connector for groups"
Causes an exception within HttpServer, headers have already been sent. This reverts commit 8187fccd258bf0936d3db8663844e07a7b81e9fc.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs274
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs3
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs142
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs217
5 files changed, 436 insertions, 206 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
index 00fe5df..185d44d 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
@@ -28,41 +28,30 @@
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>();
57 51
58 private IMessageTransferModule m_msgTransferModule = null; 52 private IMessageTransferModule m_msgTransferModule = null;
59 53
60 private IGroupsModule m_groupsModule = null; 54 private IGroupsServicesConnector m_groupData = null;
61
62 // TODO: Move this off to the Groups Server
63 public Dictionary<Guid, List<Guid>> m_agentsInGroupSession = new Dictionary<Guid, List<Guid>>();
64 public Dictionary<Guid, List<Guid>> m_agentsDroppedSession = new Dictionary<Guid, List<Guid>>();
65
66 55
67 // Config Options 56 // Config Options
68 private bool m_groupMessagingEnabled = false; 57 private bool m_groupMessagingEnabled = false;
@@ -108,8 +97,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
108 97
109 public void AddRegion(Scene scene) 98 public void AddRegion(Scene scene)
110 { 99 {
111 // NoOp 100 if (!m_groupMessagingEnabled)
101 return;
102
103 scene.RegisterModuleInterface<IGroupsMessagingModule>(this);
112 } 104 }
105
113 public void RegionLoaded(Scene scene) 106 public void RegionLoaded(Scene scene)
114 { 107 {
115 if (!m_groupMessagingEnabled) 108 if (!m_groupMessagingEnabled)
@@ -117,12 +110,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
117 110
118 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 111 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
119 112
120 m_groupsModule = scene.RequestModuleInterface<IGroupsModule>(); 113 m_groupData = scene.RequestModuleInterface<IGroupsServicesConnector>();
121 114
122 // No groups module, no groups messaging 115 // No groups module, no groups messaging
123 if (m_groupsModule == null) 116 if (m_groupData == null)
124 { 117 {
125 m_log.Error("[GROUPS-MESSAGING]: Could not get IGroupsModule, GroupsMessagingModule is now disabled."); 118 m_log.Error("[GROUPS-MESSAGING]: Could not get IGroupsServicesConnector, GroupsMessagingModule is now disabled.");
126 Close(); 119 Close();
127 m_groupMessagingEnabled = false; 120 m_groupMessagingEnabled = false;
128 return; 121 return;
@@ -144,7 +137,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
144 137
145 scene.EventManager.OnNewClient += OnNewClient; 138 scene.EventManager.OnNewClient += OnNewClient;
146 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; 139 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
147 140 scene.EventManager.OnClientLogin += OnClientLogin;
148 } 141 }
149 142
150 public void RemoveRegion(Scene scene) 143 public void RemoveRegion(Scene scene)
@@ -172,7 +165,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
172 165
173 m_sceneList.Clear(); 166 m_sceneList.Clear();
174 167
175 m_groupsModule = null; 168 m_groupData = null;
176 m_msgTransferModule = null; 169 m_msgTransferModule = null;
177 } 170 }
178 171
@@ -197,8 +190,84 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
197 190
198 #endregion 191 #endregion
199 192
193 /// <summary>
194 /// Not really needed, but does confirm that the group exists.
195 /// </summary>
196 public bool StartGroupChatSession(UUID agentID, UUID groupID)
197 {
198 if (m_debugEnabled)
199 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
200
201 GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null);
202
203 if (groupInfo != null)
204 {
205 return true;
206 }
207 else
208 {
209 return false;
210 }
211 }
212
213 public void SendMessageToGroup(GridInstantMessage im, UUID groupID)
214 {
215 if (m_debugEnabled)
216 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
217
218
219 foreach (GroupMembersData member in m_groupData.GetGroupMembers(UUID.Zero, groupID))
220 {
221 if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID))
222 {
223 // Don't deliver messages to people who have dropped this session
224 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID);
225 continue;
226 }
227
228 // Copy Message
229 GridInstantMessage msg = new GridInstantMessage();
230 msg.imSessionID = groupID.Guid;
231 msg.fromAgentName = im.fromAgentName;
232 msg.message = im.message;
233 msg.dialog = im.dialog;
234 msg.offline = im.offline;
235 msg.ParentEstateID = im.ParentEstateID;
236 msg.Position = im.Position;
237 msg.RegionID = im.RegionID;
238 msg.binaryBucket = im.binaryBucket;
239 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
240
241 msg.fromAgentID = im.fromAgentID;
242 msg.fromGroup = true;
243
244 msg.toAgentID = member.AgentID.Guid;
245
246 IClientAPI client = GetActiveClient(member.AgentID);
247 if (client == null)
248 {
249 // If they're not local, forward across the grid
250 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID);
251 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
252 }
253 else
254 {
255 // Deliver locally, directly
256 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name);
257 ProcessMessageFromGroupSession(msg);
258 }
259 }
260 }
261
200 #region SimGridEventHandlers 262 #region SimGridEventHandlers
201 263
264 void OnClientLogin(IClientAPI client)
265 {
266 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name);
267
268
269 }
270
202 private void OnNewClient(IClientAPI client) 271 private void OnNewClient(IClientAPI client)
203 { 272 {
204 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name); 273 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name);
@@ -236,42 +305,46 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
236 { 305 {
237 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); 306 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID);
238 307
308 UUID AgentID = new UUID(msg.fromAgentID);
309 UUID GroupID = new UUID(msg.imSessionID);
310
239 switch (msg.dialog) 311 switch (msg.dialog)
240 { 312 {
241 case (byte)InstantMessageDialog.SessionAdd: 313 case (byte)InstantMessageDialog.SessionAdd:
242 AddAgentToGroupSession(msg.fromAgentID, msg.imSessionID); 314 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
243 break; 315 break;
244 316
245 case (byte)InstantMessageDialog.SessionDrop: 317 case (byte)InstantMessageDialog.SessionDrop:
246 RemoveAgentFromGroupSession(msg.fromAgentID, msg.imSessionID); 318 m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID);
247 break; 319 break;
248 320
249 case (byte)InstantMessageDialog.SessionSend: 321 case (byte)InstantMessageDialog.SessionSend:
250 if (!m_agentsInGroupSession.ContainsKey(msg.toAgentID) 322 if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)
251 && !m_agentsDroppedSession.ContainsKey(msg.toAgentID)) 323 && !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID)
324 )
252 { 325 {
253 // Agent not in session and hasn't dropped from session 326 // Agent not in session and hasn't dropped from session
254 // Add them to the session for now, and Invite them 327 // Add them to the session for now, and Invite them
255 AddAgentToGroupSession(msg.toAgentID, msg.imSessionID); 328 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
256 329
257 UUID toAgentID = new UUID(msg.toAgentID); 330 UUID toAgentID = new UUID(msg.toAgentID);
258 IClientAPI activeClient = GetActiveClient(toAgentID); 331 IClientAPI activeClient = GetActiveClient(toAgentID);
259 if (activeClient != null) 332 if (activeClient != null)
260 { 333 {
261 UUID groupID = new UUID(msg.fromAgentID); 334 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
262
263 GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID);
264 if (groupInfo != null) 335 if (groupInfo != null)
265 { 336 {
266 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message"); 337 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
267 338
268 // Force? open the group session dialog??? 339 // Force? open the group session dialog???
340 // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
269 IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>(); 341 IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>();
270 eq.ChatterboxInvitation( 342 eq.ChatterboxInvitation(
271 groupID 343 GroupID
272 , groupInfo.GroupName 344 , groupInfo.GroupName
273 , new UUID(msg.fromAgentID) 345 , new UUID(msg.fromAgentID)
274 , msg.message, new UUID(msg.toAgentID) 346 , msg.message
347 , new UUID(msg.toAgentID)
275 , msg.fromAgentName 348 , msg.fromAgentName
276 , msg.dialog 349 , msg.dialog
277 , msg.timestamp 350 , msg.timestamp
@@ -285,7 +358,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
285 ); 358 );
286 359
287 eq.ChatterBoxSessionAgentListUpdates( 360 eq.ChatterBoxSessionAgentListUpdates(
288 new UUID(groupID) 361 new UUID(GroupID)
289 , new UUID(msg.fromAgentID) 362 , new UUID(msg.fromAgentID)
290 , new UUID(msg.toAgentID) 363 , new UUID(msg.toAgentID)
291 , false //canVoiceChat 364 , false //canVoiceChat
@@ -295,7 +368,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
295 } 368 }
296 } 369 }
297 } 370 }
298 else if (!m_agentsDroppedSession.ContainsKey(msg.toAgentID)) 371 else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID))
299 { 372 {
300 // User hasn't dropped, so they're in the session, 373 // User hasn't dropped, so they're in the session,
301 // maybe we should deliver it. 374 // maybe we should deliver it.
@@ -321,56 +394,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
321 394
322 #endregion 395 #endregion
323 396
324 #region ClientEvents
325
326 private void RemoveAgentFromGroupSession(Guid agentID, Guid sessionID)
327 {
328 if (m_agentsInGroupSession.ContainsKey(sessionID))
329 {
330 // If in session remove
331 if (m_agentsInGroupSession[sessionID].Contains(agentID))
332 {
333 m_agentsInGroupSession[sessionID].Remove(agentID);
334 }
335
336 // If not in dropped list, add
337 if (!m_agentsDroppedSession[sessionID].Contains(agentID))
338 {
339 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Dropped {1} from session {0}", sessionID, agentID);
340 m_agentsDroppedSession[sessionID].Add(agentID);
341 }
342 }
343 }
344
345 private void AddAgentToGroupSession(Guid agentID, Guid sessionID)
346 {
347 // Add Session Status if it doesn't exist for this session
348 CreateGroupSessionTracking(sessionID);
349
350 // If nessesary, remove from dropped list
351 if (m_agentsDroppedSession[sessionID].Contains(agentID))
352 {
353 m_agentsDroppedSession[sessionID].Remove(agentID);
354 }
355
356 // If nessesary, add to in session list
357 if (!m_agentsInGroupSession[sessionID].Contains(agentID))
358 {
359 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Added {1} to session {0}", sessionID, agentID);
360 m_agentsInGroupSession[sessionID].Add(agentID);
361 }
362 }
363
364 private void CreateGroupSessionTracking(Guid sessionID)
365 {
366 if (!m_agentsInGroupSession.ContainsKey(sessionID))
367 {
368 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Creating session tracking for : {0}", sessionID);
369 m_agentsInGroupSession.Add(sessionID, new List<Guid>());
370 m_agentsDroppedSession.Add(sessionID, new List<Guid>());
371 }
372 }
373 397
398 #region ClientEvents
374 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 399 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
375 { 400 {
376 if (m_debugEnabled) 401 if (m_debugEnabled)
@@ -383,21 +408,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
383 // Start group IM session 408 // Start group IM session
384 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) 409 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
385 { 410 {
386 UUID groupID = new UUID(im.toAgentID); 411 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID);
387 412
388 GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID); 413 UUID GroupID = new UUID(im.imSessionID);
414 UUID AgentID = new UUID(im.fromAgentID);
415
416 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
417
389 if (groupInfo != null) 418 if (groupInfo != null)
390 { 419 {
391 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Start Group Session for {0}", groupInfo.GroupName); 420 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
392
393 AddAgentToGroupSession(im.fromAgentID, im.imSessionID);
394 421
395 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, groupID); 422 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
396 423
397 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 424 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
398 queue.ChatterBoxSessionAgentListUpdates( 425 queue.ChatterBoxSessionAgentListUpdates(
399 new UUID(groupID) 426 GroupID
400 , new UUID(im.fromAgentID) 427 , AgentID
401 , new UUID(im.toAgentID) 428 , new UUID(im.toAgentID)
402 , false //canVoiceChat 429 , false //canVoiceChat
403 , false //isModerator 430 , false //isModerator
@@ -409,64 +436,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
409 // Send a message from locally connected client to a group 436 // Send a message from locally connected client to a group
410 if ((im.dialog == (byte)InstantMessageDialog.SessionSend)) 437 if ((im.dialog == (byte)InstantMessageDialog.SessionSend))
411 { 438 {
412 UUID groupID = new UUID(im.toAgentID); 439 UUID GroupID = new UUID(im.imSessionID);
440 UUID AgentID = new UUID(im.fromAgentID);
441
442 if (m_debugEnabled)
443 m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString());
413 444
414 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", groupID, im.imSessionID.ToString()); 445 //If this agent is sending a message, then they want to be in the session
446 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
415 447
416 SendMessageToGroup(im, groupID); 448 SendMessageToGroup(im, GroupID);
417 } 449 }
418 } 450 }
419 451
420 #endregion 452 #endregion
421 453
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) 454 void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID)
471 { 455 {
472 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 456 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -518,6 +502,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
518 /// </summary> 502 /// </summary>
519 private IClientAPI GetActiveClient(UUID agentID) 503 private IClientAPI GetActiveClient(UUID agentID)
520 { 504 {
505 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID);
506
521 IClientAPI child = null; 507 IClientAPI child = null;
522 508
523 // Try root avatar first 509 // Try root avatar first
@@ -529,16 +515,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
529 ScenePresence user = (ScenePresence)scene.Entities[agentID]; 515 ScenePresence user = (ScenePresence)scene.Entities[agentID];
530 if (!user.IsChildAgent) 516 if (!user.IsChildAgent)
531 { 517 {
518 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name);
532 return user.ControllingClient; 519 return user.ControllingClient;
533 } 520 }
534 else 521 else
535 { 522 {
523 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name);
536 child = user.ControllingClient; 524 child = user.ControllingClient;
537 } 525 }
538 } 526 }
539 } 527 }
540 528
541 // If we didn't find a root, then just return whichever child we found, or null if none 529 // If we didn't find a root, then just return whichever child we found, or null if none
530 if (child == null)
531 {
532 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID);
533 }
534 else
535 {
536 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name);
537 }
542 return child; 538 return child;
543 } 539 }
544 540
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index b2b8110..56c0d98 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -176,7 +176,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
176 176
177 scene.EventManager.OnNewClient += OnNewClient; 177 scene.EventManager.OnNewClient += OnNewClient;
178 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; 178 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
179
180 // The InstantMessageModule itself doesn't do this, 179 // The InstantMessageModule itself doesn't do this,
181 // so lets see if things explode if we don't do it 180 // so lets see if things explode if we don't do it
182 // scene.EventManager.OnClientClosed += OnClientClosed; 181 // scene.EventManager.OnClientClosed += OnClientClosed;
@@ -510,7 +509,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
510 IClientAPI ejectee = GetActiveClient(ejecteeID); 509 IClientAPI ejectee = GetActiveClient(ejecteeID);
511 if (ejectee != null) 510 if (ejectee != null)
512 { 511 {
513 UUID groupID = new UUID(im.fromAgentID); 512 UUID groupID = new UUID(im.imSessionID);
514 ejectee.SendAgentDropGroup(groupID); 513 ejectee.SendAgentDropGroup(groupID);
515 } 514 }
516 } 515 }
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
index 6487967..a046e09 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
@@ -71,6 +71,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
71 void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); 71 void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket);
72 GroupNoticeInfo GetGroupNotice(UUID RequestingAgentID, UUID noticeID); 72 GroupNoticeInfo GetGroupNotice(UUID RequestingAgentID, UUID noticeID);
73 List<GroupNoticeData> GetGroupNotices(UUID RequestingAgentID, UUID GroupID); 73 List<GroupNoticeData> GetGroupNotices(UUID RequestingAgentID, UUID GroupID);
74
75 void ResetAgentGroupChatSessions(UUID agentID);
76 bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID);
77 bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID);
78 void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID);
79 void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID);
74 } 80 }
75 81
76 public class GroupInviteInfo 82 public class GroupInviteInfo
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
index bc05b0f..9363205 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
@@ -55,6 +55,9 @@ using OpenSim.Services.Interfaces;
55 * UserID -> Group -> ActiveGroup 55 * UserID -> Group -> ActiveGroup
56 * + GroupID 56 * + GroupID
57 * 57 *
58 * UserID -> GroupSessionDropped -> GroupID
59 * UserID -> GroupSessionInvited -> GroupID
60 *
58 * UserID -> GroupMember -> GroupID 61 * UserID -> GroupMember -> GroupID
59 * + SelectedRoleID [UUID] 62 * + SelectedRoleID [UUID]
60 * + AcceptNotices [bool] 63 * + AcceptNotices [bool]
@@ -63,6 +66,7 @@ using OpenSim.Services.Interfaces;
63 * 66 *
64 * UserID -> GroupRole[GroupID] -> RoleID 67 * UserID -> GroupRole[GroupID] -> RoleID
65 * 68 *
69 *
66 * GroupID -> Group -> GroupName 70 * GroupID -> Group -> GroupName
67 * + Charter 71 * + Charter
68 * + ShowInList 72 * + ShowInList
@@ -159,10 +163,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
159 163
160 private bool m_connectorEnabled = false; 164 private bool m_connectorEnabled = false;
161 165
162 private string m_serviceURL = string.Empty; 166 private string m_groupsServerURI = string.Empty;
163 167
164 private bool m_debugEnabled = false; 168 private bool m_debugEnabled = false;
165 169
170 private ExpiringCache<string, OSDMap> m_memoryCache;
171 private int m_cacheTimeout = 30;
172
166 // private IUserAccountService m_accountService = null; 173 // private IUserAccountService m_accountService = null;
167 174
168 175
@@ -199,17 +206,33 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
199 return; 206 return;
200 } 207 }
201 208
202 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); 209 m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Initializing {0}", this.Name);
203 210
204 m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty); 211 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
205 if ((m_serviceURL == null) || 212 if ((m_groupsServerURI == null) ||
206 (m_serviceURL == string.Empty)) 213 (m_groupsServerURI == string.Empty))
207 { 214 {
208 m_log.ErrorFormat("Please specify a valid Simian Server URL for XmlRpcServiceURL in OpenSim.ini, [Groups]"); 215 m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]");
209 m_connectorEnabled = false; 216 m_connectorEnabled = false;
210 return; 217 return;
211 } 218 }
212 219
220
221 m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30);
222 if (m_cacheTimeout == 0)
223 {
224 m_log.WarnFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Disabled.");
225 }
226 else
227 {
228 m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Timeout set to {0}.", m_cacheTimeout);
229 }
230
231
232
233 m_memoryCache = new ExpiringCache<string,OSDMap>();
234
235
213 // If we got all the config options we need, lets start'er'up 236 // If we got all the config options we need, lets start'er'up
214 m_connectorEnabled = true; 237 m_connectorEnabled = true;
215 238
@@ -220,7 +243,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
220 243
221 public void Close() 244 public void Close()
222 { 245 {
223 m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name); 246 m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Closing {0}", this.Name);
224 } 247 }
225 248
226 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) 249 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -653,7 +676,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
653 }; 676 };
654 677
655 678
656 OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs); 679 OSDMap response = CachedPostRequest(requestArgs);
657 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) 680 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
658 { 681 {
659 OSDArray entryArray = (OSDArray)response["Entries"]; 682 OSDArray entryArray = (OSDArray)response["Entries"];
@@ -998,6 +1021,52 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
998 } 1021 }
999 #endregion 1022 #endregion
1000 1023
1024 #region GroupSessionTracking
1025
1026 public void ResetAgentGroupChatSessions(UUID agentID)
1027 {
1028 Dictionary<string, OSDMap> agentSessions;
1029
1030 if (SimianGetGenericEntries(agentID, "GroupSessionDropped", out agentSessions))
1031 {
1032 foreach (string GroupID in agentSessions.Keys)
1033 {
1034 SimianRemoveGenericEntry(agentID, "GroupSessionDropped", GroupID);
1035 }
1036 }
1037
1038 if (SimianGetGenericEntries(agentID, "GroupSessionInvited", out agentSessions))
1039 {
1040 foreach (string GroupID in agentSessions.Keys)
1041 {
1042 SimianRemoveGenericEntry(agentID, "GroupSessionInvited", GroupID);
1043 }
1044 }
1045 }
1046
1047 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
1048 {
1049 OSDMap session;
1050 return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session);
1051 }
1052
1053 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
1054 {
1055 SimianAddGeneric(agentID, "GroupSessionDropped", groupID.ToString(), new OSDMap());
1056 }
1057
1058 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
1059 {
1060 SimianAddGeneric(agentID, "GroupSessionInvited", groupID.ToString(), new OSDMap());
1061 }
1062
1063 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
1064 {
1065 OSDMap session;
1066 return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session);
1067 }
1068
1069 #endregion
1001 1070
1002 private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID) 1071 private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID)
1003 { 1072 {
@@ -1036,7 +1105,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1036 }; 1105 };
1037 1106
1038 1107
1039 OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs); 1108 OSDMap Response = CachedPostRequest(RequestArgs);
1040 if (Response["Success"].AsBoolean()) 1109 if (Response["Success"].AsBoolean())
1041 { 1110 {
1042 return true; 1111 return true;
@@ -1063,7 +1132,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1063 }; 1132 };
1064 1133
1065 1134
1066 OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs); 1135 OSDMap Response = CachedPostRequest(RequestArgs);
1067 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) 1136 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1068 { 1137 {
1069 OSDArray entryArray = (OSDArray)Response["Entries"]; 1138 OSDArray entryArray = (OSDArray)Response["Entries"];
@@ -1103,7 +1172,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1103 }; 1172 };
1104 1173
1105 1174
1106 OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs); 1175 OSDMap Response = CachedPostRequest(RequestArgs);
1107 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) 1176 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1108 { 1177 {
1109 OSDArray entryArray = (OSDArray)Response["Entries"]; 1178 OSDArray entryArray = (OSDArray)Response["Entries"];
@@ -1144,7 +1213,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1144 }; 1213 };
1145 1214
1146 1215
1147 OSDMap Response = WebUtil.PostToService(m_serviceURL, RequestArgs); 1216 OSDMap Response = CachedPostRequest(RequestArgs);
1148 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) 1217 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1149 { 1218 {
1150 OSDArray entryArray = (OSDArray)Response["Entries"]; 1219 OSDArray entryArray = (OSDArray)Response["Entries"];
@@ -1184,7 +1253,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1184 1253
1185 1254
1186 1255
1187 OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs); 1256 OSDMap response = CachedPostRequest(requestArgs);
1188 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) 1257 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
1189 { 1258 {
1190 maps = new Dictionary<string, OSDMap>(); 1259 maps = new Dictionary<string, OSDMap>();
@@ -1222,7 +1291,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1222 1291
1223 1292
1224 1293
1225 OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs); 1294 OSDMap response = CachedPostRequest(requestArgs);
1226 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) 1295 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
1227 { 1296 {
1228 maps = new Dictionary<UUID, OSDMap>(); 1297 maps = new Dictionary<UUID, OSDMap>();
@@ -1260,7 +1329,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1260 }; 1329 };
1261 1330
1262 1331
1263 OSDMap response = WebUtil.PostToService(m_serviceURL, requestArgs); 1332 OSDMap response = CachedPostRequest(requestArgs);
1264 if (response["Success"].AsBoolean()) 1333 if (response["Success"].AsBoolean())
1265 { 1334 {
1266 return true; 1335 return true;
@@ -1272,6 +1341,49 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1272 } 1341 }
1273 } 1342 }
1274 #endregion 1343 #endregion
1344
1345 #region CheesyCache
1346 OSDMap CachedPostRequest(NameValueCollection requestArgs)
1347 {
1348 // Immediately forward the request if the cache is disabled.
1349 if (m_cacheTimeout == 0)
1350 {
1351 return WebUtil.PostToService(m_groupsServerURI, requestArgs);
1352 }
1353
1354 // Check if this is an update or a request
1355 if ( requestArgs["RequestMethod"] == "RemoveGeneric"
1356 || requestArgs["RequestMethod"] == "AddGeneric"
1357 )
1358
1359 {
1360 // Any and all updates cause the cache to clear
1361 m_memoryCache.Clear();
1362
1363 // Send update to server, return the response without caching it
1364 return WebUtil.PostToService(m_groupsServerURI, requestArgs);
1365
1366 }
1367
1368 // If we're not doing an update, we must be requesting data
1369
1370 // Create the cache key for the request and see if we have it cached
1371 string CacheKey = WebUtil.BuildQueryString(requestArgs);
1372 OSDMap response = null;
1373 if (!m_memoryCache.TryGetValue(CacheKey, out response))
1374 {
1375 // if it wasn't in the cache, pass the request to the Simian Grid Services
1376 response = WebUtil.PostToService(m_groupsServerURI, requestArgs);
1377
1378 // and cache the response
1379 m_memoryCache.AddOrUpdate(CacheKey, response, TimeSpan.FromSeconds(m_cacheTimeout));
1380 }
1381
1382 // return cached response
1383 return response;
1384 }
1385 #endregion
1386
1275 } 1387 }
1276 1388
1277} 1389}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index ab343c8..79b9a16 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using System.Text;
32 33
33using Nwc.XmlRpc; 34using Nwc.XmlRpc;
34 35
@@ -61,7 +62,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
61 62
62 private bool m_connectorEnabled = false; 63 private bool m_connectorEnabled = false;
63 64
64 private string m_serviceURL = string.Empty; 65 private string m_groupsServerURI = string.Empty;
65 66
66 private bool m_disableKeepAlive = false; 67 private bool m_disableKeepAlive = false;
67 68
@@ -69,7 +70,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
69 private string m_groupWriteKey = string.Empty; 70 private string m_groupWriteKey = string.Empty;
70 71
71 private IUserAccountService m_accountService = null; 72 private IUserAccountService m_accountService = null;
72 73
74 private ExpiringCache<string, XmlRpcResponse> m_memoryCache;
75 private int m_cacheTimeout = 30;
76
77 // Used to track which agents are have dropped from a group chat session
78 // Should be reset per agent, on logon
79 // TODO: move this to Flotsam XmlRpc Service
80 // SessionID, List<AgentID>
81 private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>();
82 private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>();
83
73 84
74 #region IRegionModuleBase Members 85 #region IRegionModuleBase Members
75 86
@@ -104,13 +115,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
104 return; 115 return;
105 } 116 }
106 117
107 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); 118 m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Initializing {0}", this.Name);
108 119
109 m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty); 120 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
110 if ((m_serviceURL == null) || 121 if ((m_groupsServerURI == null) ||
111 (m_serviceURL == string.Empty)) 122 (m_groupsServerURI == string.Empty))
112 { 123 {
113 m_log.ErrorFormat("Please specify a valid URL for XmlRpcServiceURL in OpenSim.ini, [Groups]"); 124 m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]");
114 m_connectorEnabled = false; 125 m_connectorEnabled = false;
115 return; 126 return;
116 } 127 }
@@ -120,17 +131,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
120 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); 131 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
121 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); 132 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
122 133
123
124 134
135 m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30);
136 if (m_cacheTimeout == 0)
137 {
138 m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Disabled.");
139 }
140 else
141 {
142 m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Timeout set to {0}.", m_cacheTimeout);
143 }
125 144
126 // If we got all the config options we need, lets start'er'up 145 // If we got all the config options we need, lets start'er'up
146 m_memoryCache = new ExpiringCache<string, XmlRpcResponse>();
127 m_connectorEnabled = true; 147 m_connectorEnabled = true;
128 } 148 }
129 } 149 }
130 150
131 public void Close() 151 public void Close()
132 { 152 {
133 m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name); 153 m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Closing {0}", this.Name);
134 } 154 }
135 155
136 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) 156 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -756,6 +776,69 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
756 776
757 XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param); 777 XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param);
758 } 778 }
779
780
781
782 #endregion
783
784 #region GroupSessionTracking
785
786 public void ResetAgentGroupChatSessions(UUID agentID)
787 {
788 foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values)
789 {
790 agentList.Remove(agentID);
791 }
792 }
793
794 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
795 {
796 // If we're tracking this group, and we can find them in the tracking, then they've been invited
797 return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID)
798 && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID);
799 }
800
801 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
802 {
803 // If we're tracking drops for this group,
804 // and we find them, well... then they've dropped
805 return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)
806 && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID);
807 }
808
809 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
810 {
811 if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
812 {
813 // If not in dropped list, add
814 if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
815 {
816 m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
817 }
818 }
819 }
820
821 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
822 {
823 // Add Session Status if it doesn't exist for this session
824 CreateGroupChatSessionTracking(groupID);
825
826 // If nessesary, remove from dropped list
827 if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
828 {
829 m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
830 }
831 }
832
833 private void CreateGroupChatSessionTracking(UUID groupID)
834 {
835 if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
836 {
837 m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>());
838 m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>());
839 }
840
841 }
759 #endregion 842 #endregion
760 843
761 #region XmlRpcHashtableMarshalling 844 #region XmlRpcHashtableMarshalling
@@ -849,50 +932,84 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
849 /// </summary> 932 /// </summary>
850 private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param) 933 private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param)
851 { 934 {
852 string UserService; 935 XmlRpcResponse resp = null;
853 UUID SessionID; 936 string CacheKey = null;
854 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID); 937
855 param.Add("requestingAgentID", requestingAgentID.ToString()); 938 // Only bother with the cache if it isn't disabled.
856 param.Add("RequestingAgentUserService", UserService); 939 if (m_cacheTimeout > 0)
857 param.Add("RequestingSessionID", SessionID.ToString()); 940 {
858 941 if (!function.StartsWith("groups.get"))
942 {
943 // Any and all updates cause the cache to clear
944 m_memoryCache.Clear();
945 }
946 else
947 {
948 StringBuilder sb = new StringBuilder(requestingAgentID + function);
949 foreach (object key in param.Keys)
950 {
951 if (param[key] != null)
952 {
953 sb.AppendFormat(",{0}:{1}", key.ToString(), param[key].ToString());
954 }
955 }
956
957 CacheKey = sb.ToString();
958 m_memoryCache.TryGetValue(CacheKey, out resp);
959 }
859 960
860 param.Add("ReadKey", m_groupReadKey); 961 }
861 param.Add("WriteKey", m_groupWriteKey); 962
963 if( resp == null )
964 {
965 string UserService;
966 UUID SessionID;
967 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
968 param.Add("requestingAgentID", requestingAgentID.ToString());
969 param.Add("RequestingAgentUserService", UserService);
970 param.Add("RequestingSessionID", SessionID.ToString());
862 971
863 972
864 IList parameters = new ArrayList(); 973 param.Add("ReadKey", m_groupReadKey);
865 parameters.Add(param); 974 param.Add("WriteKey", m_groupWriteKey);
866 975
867 ConfigurableKeepAliveXmlRpcRequest req;
868 req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
869 976
870 XmlRpcResponse resp = null; 977 IList parameters = new ArrayList();
978 parameters.Add(param);
871 979
872 try 980 ConfigurableKeepAliveXmlRpcRequest req;
873 { 981 req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
874 resp = req.Send(m_serviceURL, 10000);
875 }
876 catch (Exception e)
877 {
878
879 982
880 m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
881 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString());
882 983
883 foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine },StringSplitOptions.None)) 984 try
884 { 985 {
885 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine); 986 resp = req.Send(m_groupsServerURI, 10000);
886 }
887 987
888 foreach (string key in param.Keys) 988 if ((m_cacheTimeout > 0) && (CacheKey != null))
989 {
990 m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout));
991 }
992
993 }
994 catch (Exception e)
889 { 995 {
890 m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", key, param[key].ToString()); 996 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
997 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", e.ToString());
998
999 foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
1000 {
1001 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", ResponseLine);
1002 }
1003
1004 foreach (string key in param.Keys)
1005 {
1006 m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", key, param[key].ToString());
1007 }
1008
1009 Hashtable respData = new Hashtable();
1010 respData.Add("error", e.ToString());
1011 return respData;
891 } 1012 }
892
893 Hashtable respData = new Hashtable();
894 respData.Add("error", e.ToString());
895 return respData;
896 } 1013 }
897 1014
898 if (resp.Value is Hashtable) 1015 if (resp.Value is Hashtable)
@@ -906,21 +1023,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
906 return respData; 1023 return respData;
907 } 1024 }
908 1025
909 m_log.ErrorFormat("[XMLRPCGROUPDATA]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString()); 1026 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString());
910 1027
911 if (resp.Value is ArrayList) 1028 if (resp.Value is ArrayList)
912 { 1029 {
913 ArrayList al = (ArrayList)resp.Value; 1030 ArrayList al = (ArrayList)resp.Value;
914 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Contains {0} elements", al.Count); 1031 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Contains {0} elements", al.Count);
915 1032
916 foreach (object o in al) 1033 foreach (object o in al)
917 { 1034 {
918 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} :: {1}", o.GetType().ToString(), o.ToString()); 1035 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", o.GetType().ToString(), o.ToString());
919 } 1036 }
920 } 1037 }
921 else 1038 else
922 { 1039 {
923 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Function returned: {0}", resp.Value.ToString()); 1040 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Function returned: {0}", resp.Value.ToString());
924 } 1041 }
925 1042
926 Hashtable error = new Hashtable(); 1043 Hashtable error = new Hashtable();
@@ -930,16 +1047,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
930 1047
931 private void LogRespDataToConsoleError(Hashtable respData) 1048 private void LogRespDataToConsoleError(Hashtable respData)
932 { 1049 {
933 m_log.Error("[XMLRPCGROUPDATA]: Error:"); 1050 m_log.Error("[XMLRPC-GROUPS-CONNECTOR]: Error:");
934 1051
935 foreach (string key in respData.Keys) 1052 foreach (string key in respData.Keys)
936 { 1053 {
937 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Key: {0}", key); 1054 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Key: {0}", key);
938 1055
939 string[] lines = respData[key].ToString().Split(new char[] { '\n' }); 1056 string[] lines = respData[key].ToString().Split(new char[] { '\n' });
940 foreach (string line in lines) 1057 foreach (string line in lines)
941 { 1058 {
942 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0}", line); 1059 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", line);
943 } 1060 }
944 1061
945 } 1062 }
@@ -948,8 +1065,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
948 1065
949 /// <summary> 1066 /// <summary>
950 /// Group Request Tokens are an attempt to allow the groups service to authenticate 1067 /// Group Request Tokens are an attempt to allow the groups service to authenticate
951 /// requests. Currently uses UserService, AgentID, and SessionID 1068 /// requests.
952 /// TODO: Find a better way to do this. 1069 /// TODO: This broke after the big grid refactor, either find a better way, or discard this
953 /// </summary> 1070 /// </summary>
954 /// <param name="client"></param> 1071 /// <param name="client"></param>
955 /// <returns></returns> 1072 /// <returns></returns>