aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs128
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs12
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs183
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs273
6 files changed, 356 insertions, 248 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
index e664b44..d49a489 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
@@ -109,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
109 } 109 }
110 else 110 else
111 { 111 {
112 m_log.WarnFormat("[IRC-Bridge] Not enabled. Connect for region {0} ignored", scene.RegionInfo.RegionName); 112 //m_log.DebugFormat("[IRC-Bridge] Not enabled. Connect for region {0} ignored", scene.RegionInfo.RegionName);
113 } 113 }
114 } 114 }
115 115
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
index 17a5349..185d44d 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
@@ -49,9 +49,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
49 49
50 private List<Scene> m_sceneList = new List<Scene>(); 50 private List<Scene> m_sceneList = new List<Scene>();
51 51
52 private IMessageTransferModule m_msgTransferModule = null; 52 private IMessageTransferModule m_msgTransferModule = null;
53 53
54 private IGroupsServicesConnector m_groupData = null; 54 private IGroupsServicesConnector m_groupData = null;
55 55
56 // Config Options 56 // Config Options
57 private bool m_groupMessagingEnabled = false; 57 private bool m_groupMessagingEnabled = false;
@@ -108,13 +108,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
108 if (!m_groupMessagingEnabled) 108 if (!m_groupMessagingEnabled)
109 return; 109 return;
110 110
111 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);
112 112
113 m_groupData = scene.RequestModuleInterface<IGroupsServicesConnector>(); 113 m_groupData = scene.RequestModuleInterface<IGroupsServicesConnector>();
114 114
115 // No groups module, no groups messaging 115 // No groups module, no groups messaging
116 if (m_groupData == null) 116 if (m_groupData == null)
117 { 117 {
118 m_log.Error("[GROUPS-MESSAGING]: Could not get IGroupsServicesConnector, GroupsMessagingModule is now disabled."); 118 m_log.Error("[GROUPS-MESSAGING]: Could not get IGroupsServicesConnector, GroupsMessagingModule is now disabled.");
119 Close(); 119 Close();
120 m_groupMessagingEnabled = false; 120 m_groupMessagingEnabled = false;
@@ -190,9 +190,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
190 190
191 #endregion 191 #endregion
192 192
193 /// <summary> 193 /// <summary>
194 /// Not really needed, but does confirm that the group exists. 194 /// Not really needed, but does confirm that the group exists.
195 /// </summary> 195 /// </summary>
196 public bool StartGroupChatSession(UUID agentID, UUID groupID) 196 public bool StartGroupChatSession(UUID agentID, UUID groupID)
197 { 197 {
198 if (m_debugEnabled) 198 if (m_debugEnabled)
@@ -201,7 +201,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
201 GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null); 201 GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null);
202 202
203 if (groupInfo != null) 203 if (groupInfo != null)
204 { 204 {
205 return true; 205 return true;
206 } 206 }
207 else 207 else
@@ -213,11 +213,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
213 public void SendMessageToGroup(GridInstantMessage im, UUID groupID) 213 public void SendMessageToGroup(GridInstantMessage im, UUID groupID)
214 { 214 {
215 if (m_debugEnabled) 215 if (m_debugEnabled)
216 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 216 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
217 217
218 218
219 foreach (GroupMembersData member in m_groupData.GetGroupMembers(UUID.Zero, groupID)) 219 foreach (GroupMembersData member in m_groupData.GetGroupMembers(UUID.Zero, groupID))
220 { 220 {
221 if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID)) 221 if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID))
222 { 222 {
223 // Don't deliver messages to people who have dropped this session 223 // Don't deliver messages to people who have dropped this session
@@ -226,7 +226,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
226 } 226 }
227 227
228 // Copy Message 228 // Copy Message
229 GridInstantMessage msg = new GridInstantMessage(); 229 GridInstantMessage msg = new GridInstantMessage();
230 msg.imSessionID = groupID.Guid; 230 msg.imSessionID = groupID.Guid;
231 msg.fromAgentName = im.fromAgentName; 231 msg.fromAgentName = im.fromAgentName;
232 msg.message = im.message; 232 msg.message = im.message;
@@ -259,13 +259,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
259 } 259 }
260 } 260 }
261 261
262 #region SimGridEventHandlers 262 #region SimGridEventHandlers
263 263
264 void OnClientLogin(IClientAPI client) 264 void OnClientLogin(IClientAPI client)
265 { 265 {
266 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name); 266 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name);
267 267
268 268
269 } 269 }
270 270
271 private void OnNewClient(IClientAPI client) 271 private void OnNewClient(IClientAPI client)
@@ -303,28 +303,28 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
303 303
304 private void ProcessMessageFromGroupSession(GridInstantMessage msg) 304 private void ProcessMessageFromGroupSession(GridInstantMessage msg)
305 { 305 {
306 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);
307 307
308 UUID AgentID = new UUID(msg.fromAgentID); 308 UUID AgentID = new UUID(msg.fromAgentID);
309 UUID GroupID = new UUID(msg.imSessionID); 309 UUID GroupID = new UUID(msg.imSessionID);
310 310
311 switch (msg.dialog) 311 switch (msg.dialog)
312 { 312 {
313 case (byte)InstantMessageDialog.SessionAdd: 313 case (byte)InstantMessageDialog.SessionAdd:
314 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); 314 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
315 break; 315 break;
316 316
317 case (byte)InstantMessageDialog.SessionDrop: 317 case (byte)InstantMessageDialog.SessionDrop:
318 m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID); 318 m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID);
319 break; 319 break;
320 320
321 case (byte)InstantMessageDialog.SessionSend: 321 case (byte)InstantMessageDialog.SessionSend:
322 if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID) 322 if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)
323 && !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID) 323 && !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID)
324 ) 324 )
325 { 325 {
326 // Agent not in session and hasn't dropped from session 326 // Agent not in session and hasn't dropped from session
327 // Add them to the session for now, and Invite them 327 // Add them to the session for now, and Invite them
328 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); 328 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
329 329
330 UUID toAgentID = new UUID(msg.toAgentID); 330 UUID toAgentID = new UUID(msg.toAgentID);
@@ -336,10 +336,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
336 { 336 {
337 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");
338 338
339 // 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); 340 // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
341 IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>(); 341 IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>();
342 eq.ChatterboxInvitation( 342 eq.ChatterboxInvitation(
343 GroupID 343 GroupID
344 , groupInfo.GroupName 344 , groupInfo.GroupName
345 , new UUID(msg.fromAgentID) 345 , new UUID(msg.fromAgentID)
@@ -357,7 +357,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
357 , Utils.StringToBytes(groupInfo.GroupName) 357 , Utils.StringToBytes(groupInfo.GroupName)
358 ); 358 );
359 359
360 eq.ChatterBoxSessionAgentListUpdates( 360 eq.ChatterBoxSessionAgentListUpdates(
361 new UUID(GroupID) 361 new UUID(GroupID)
362 , new UUID(msg.fromAgentID) 362 , new UUID(msg.fromAgentID)
363 , new UUID(msg.toAgentID) 363 , new UUID(msg.toAgentID)
@@ -367,7 +367,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
367 ); 367 );
368 } 368 }
369 } 369 }
370 } 370 }
371 else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)) 371 else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID))
372 { 372 {
373 // User hasn't dropped, so they're in the session, 373 // User hasn't dropped, so they're in the session,
@@ -394,8 +394,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
394 394
395 #endregion 395 #endregion
396 396
397 397
398 #region ClientEvents 398 #region ClientEvents
399 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 399 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
400 { 400 {
401 if (m_debugEnabled) 401 if (m_debugEnabled)
@@ -407,23 +407,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
407 407
408 // Start group IM session 408 // Start group IM session
409 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) 409 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
410 { 410 {
411 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID); 411 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID);
412 412
413 UUID GroupID = new UUID(im.imSessionID); 413 UUID GroupID = new UUID(im.imSessionID);
414 UUID AgentID = new UUID(im.fromAgentID); 414 UUID AgentID = new UUID(im.fromAgentID);
415 415
416 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); 416 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
417 417
418 if (groupInfo != null) 418 if (groupInfo != null)
419 { 419 {
420 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); 420 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
421 421
422 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID); 422 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
423 423
424 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 424 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
425 queue.ChatterBoxSessionAgentListUpdates( 425 queue.ChatterBoxSessionAgentListUpdates(
426 GroupID 426 GroupID
427 , AgentID 427 , AgentID
428 , new UUID(im.toAgentID) 428 , new UUID(im.toAgentID)
429 , false //canVoiceChat 429 , false //canVoiceChat
@@ -435,16 +435,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
435 435
436 // Send a message from locally connected client to a group 436 // Send a message from locally connected client to a group
437 if ((im.dialog == (byte)InstantMessageDialog.SessionSend)) 437 if ((im.dialog == (byte)InstantMessageDialog.SessionSend))
438 { 438 {
439 UUID GroupID = new UUID(im.imSessionID); 439 UUID GroupID = new UUID(im.imSessionID);
440 UUID AgentID = new UUID(im.fromAgentID); 440 UUID AgentID = new UUID(im.fromAgentID);
441 441
442 if (m_debugEnabled) 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()); 443 m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString());
444 444
445 //If this agent is sending a message, then they want to be in the session 445 //If this agent is sending a message, then they want to be in the session
446 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); 446 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
447 447
448 SendMessageToGroup(im, GroupID); 448 SendMessageToGroup(im, GroupID);
449 } 449 }
450 } 450 }
@@ -501,7 +501,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
501 /// Try to find an active IClientAPI reference for agentID giving preference to root connections 501 /// Try to find an active IClientAPI reference for agentID giving preference to root connections
502 /// </summary> 502 /// </summary>
503 private IClientAPI GetActiveClient(UUID agentID) 503 private IClientAPI GetActiveClient(UUID agentID)
504 { 504 {
505 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID); 505 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID);
506 506
507 IClientAPI child = null; 507 IClientAPI child = null;
@@ -514,26 +514,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
514 { 514 {
515 ScenePresence user = (ScenePresence)scene.Entities[agentID]; 515 ScenePresence user = (ScenePresence)scene.Entities[agentID];
516 if (!user.IsChildAgent) 516 if (!user.IsChildAgent)
517 { 517 {
518 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name); 518 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name);
519 return user.ControllingClient; 519 return user.ControllingClient;
520 } 520 }
521 else 521 else
522 { 522 {
523 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name); 523 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name);
524 child = user.ControllingClient; 524 child = user.ControllingClient;
525 } 525 }
526 } 526 }
527 } 527 }
528 528
529 // 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) 530 if (child == null)
531 { 531 {
532 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID); 532 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID);
533 } 533 }
534 else 534 else
535 { 535 {
536 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name); 536 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name);
537 } 537 }
538 return child; 538 return child;
539 } 539 }
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index e5dab93..56c0d98 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -175,13 +175,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
175 } 175 }
176 176
177 scene.EventManager.OnNewClient += OnNewClient; 177 scene.EventManager.OnNewClient += OnNewClient;
178 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; 178 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
179 // The InstantMessageModule itself doesn't do this, 179 // The InstantMessageModule itself doesn't do this,
180 // 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
181 // scene.EventManager.OnClientClosed += OnClientClosed; 181 // scene.EventManager.OnClientClosed += OnClientClosed;
182 182
183 } 183 }
184 184
185 public void RemoveRegion(Scene scene) 185 public void RemoveRegion(Scene scene)
186 { 186 {
187 if (!m_groupsEnabled) 187 if (!m_groupsEnabled)
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
index 54ffc81..a046e09 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
@@ -70,12 +70,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
70 70
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 74
75 void ResetAgentGroupChatSessions(UUID agentID); 75 void ResetAgentGroupChatSessions(UUID agentID);
76 bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID); 76 bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID);
77 bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID); 77 bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID);
78 void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID); 78 void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID);
79 void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID); 79 void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID);
80 } 80 }
81 81
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
index 4867c01..9363205 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
@@ -167,6 +167,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
167 167
168 private bool m_debugEnabled = false; 168 private bool m_debugEnabled = false;
169 169
170 private ExpiringCache<string, OSDMap> m_memoryCache;
171 private int m_cacheTimeout = 30;
172
170 // private IUserAccountService m_accountService = null; 173 // private IUserAccountService m_accountService = null;
171 174
172 175
@@ -203,17 +206,33 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
203 return; 206 return;
204 } 207 }
205 208
206 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); 209 m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Initializing {0}", this.Name);
207 210
208 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); 211 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
209 if ((m_groupsServerURI == null) || 212 if ((m_groupsServerURI == null) ||
210 (m_groupsServerURI == string.Empty)) 213 (m_groupsServerURI == string.Empty))
211 { 214 {
212 m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]"); 215 m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]");
213 m_connectorEnabled = false; 216 m_connectorEnabled = false;
214 return; 217 return;
215 } 218 }
216 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
217 // 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
218 m_connectorEnabled = true; 237 m_connectorEnabled = true;
219 238
@@ -224,7 +243,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
224 243
225 public void Close() 244 public void Close()
226 { 245 {
227 m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name); 246 m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Closing {0}", this.Name);
228 } 247 }
229 248
230 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) 249 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -657,7 +676,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
657 }; 676 };
658 677
659 678
660 OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs); 679 OSDMap response = CachedPostRequest(requestArgs);
661 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) 680 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
662 { 681 {
663 OSDArray entryArray = (OSDArray)response["Entries"]; 682 OSDArray entryArray = (OSDArray)response["Entries"];
@@ -1000,53 +1019,53 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1000 SimianAddGeneric(groupID, "GroupNotice", noticeID.ToString(), Notice); 1019 SimianAddGeneric(groupID, "GroupNotice", noticeID.ToString(), Notice);
1001 1020
1002 } 1021 }
1003 #endregion 1022 #endregion
1004 1023
1005 #region GroupSessionTracking 1024 #region GroupSessionTracking
1006 1025
1007 public void ResetAgentGroupChatSessions(UUID agentID) 1026 public void ResetAgentGroupChatSessions(UUID agentID)
1008 { 1027 {
1009 Dictionary<string, OSDMap> agentSessions; 1028 Dictionary<string, OSDMap> agentSessions;
1010 1029
1011 if (SimianGetGenericEntries(agentID, "GroupSessionDropped", out agentSessions)) 1030 if (SimianGetGenericEntries(agentID, "GroupSessionDropped", out agentSessions))
1012 { 1031 {
1013 foreach (string GroupID in agentSessions.Keys) 1032 foreach (string GroupID in agentSessions.Keys)
1014 { 1033 {
1015 SimianRemoveGenericEntry(agentID, "GroupSessionDropped", GroupID); 1034 SimianRemoveGenericEntry(agentID, "GroupSessionDropped", GroupID);
1016 } 1035 }
1017 } 1036 }
1018 1037
1019 if (SimianGetGenericEntries(agentID, "GroupSessionInvited", out agentSessions)) 1038 if (SimianGetGenericEntries(agentID, "GroupSessionInvited", out agentSessions))
1020 { 1039 {
1021 foreach (string GroupID in agentSessions.Keys) 1040 foreach (string GroupID in agentSessions.Keys)
1022 { 1041 {
1023 SimianRemoveGenericEntry(agentID, "GroupSessionInvited", GroupID); 1042 SimianRemoveGenericEntry(agentID, "GroupSessionInvited", GroupID);
1024 } 1043 }
1025 } 1044 }
1026 } 1045 }
1027 1046
1028 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID) 1047 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
1029 { 1048 {
1030 OSDMap session; 1049 OSDMap session;
1031 return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session); 1050 return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session);
1032 } 1051 }
1033 1052
1034 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID) 1053 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
1035 { 1054 {
1036 SimianAddGeneric(agentID, "GroupSessionDropped", groupID.ToString(), new OSDMap()); 1055 SimianAddGeneric(agentID, "GroupSessionDropped", groupID.ToString(), new OSDMap());
1037 } 1056 }
1038 1057
1039 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID) 1058 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
1040 { 1059 {
1041 SimianAddGeneric(agentID, "GroupSessionInvited", groupID.ToString(), new OSDMap()); 1060 SimianAddGeneric(agentID, "GroupSessionInvited", groupID.ToString(), new OSDMap());
1042 } 1061 }
1043 1062
1044 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID) 1063 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
1045 { 1064 {
1046 OSDMap session; 1065 OSDMap session;
1047 return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session); 1066 return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session);
1048 } 1067 }
1049 1068
1050 #endregion 1069 #endregion
1051 1070
1052 private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID) 1071 private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID)
@@ -1086,7 +1105,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1086 }; 1105 };
1087 1106
1088 1107
1089 OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs); 1108 OSDMap Response = CachedPostRequest(RequestArgs);
1090 if (Response["Success"].AsBoolean()) 1109 if (Response["Success"].AsBoolean())
1091 { 1110 {
1092 return true; 1111 return true;
@@ -1113,7 +1132,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1113 }; 1132 };
1114 1133
1115 1134
1116 OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs); 1135 OSDMap Response = CachedPostRequest(RequestArgs);
1117 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) 1136 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1118 { 1137 {
1119 OSDArray entryArray = (OSDArray)Response["Entries"]; 1138 OSDArray entryArray = (OSDArray)Response["Entries"];
@@ -1153,7 +1172,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1153 }; 1172 };
1154 1173
1155 1174
1156 OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs); 1175 OSDMap Response = CachedPostRequest(RequestArgs);
1157 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) 1176 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1158 { 1177 {
1159 OSDArray entryArray = (OSDArray)Response["Entries"]; 1178 OSDArray entryArray = (OSDArray)Response["Entries"];
@@ -1194,7 +1213,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1194 }; 1213 };
1195 1214
1196 1215
1197 OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs); 1216 OSDMap Response = CachedPostRequest(RequestArgs);
1198 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) 1217 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1199 { 1218 {
1200 OSDArray entryArray = (OSDArray)Response["Entries"]; 1219 OSDArray entryArray = (OSDArray)Response["Entries"];
@@ -1234,7 +1253,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1234 1253
1235 1254
1236 1255
1237 OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs); 1256 OSDMap response = CachedPostRequest(requestArgs);
1238 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) 1257 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
1239 { 1258 {
1240 maps = new Dictionary<string, OSDMap>(); 1259 maps = new Dictionary<string, OSDMap>();
@@ -1272,7 +1291,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1272 1291
1273 1292
1274 1293
1275 OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs); 1294 OSDMap response = CachedPostRequest(requestArgs);
1276 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) 1295 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
1277 { 1296 {
1278 maps = new Dictionary<UUID, OSDMap>(); 1297 maps = new Dictionary<UUID, OSDMap>();
@@ -1310,7 +1329,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1310 }; 1329 };
1311 1330
1312 1331
1313 OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs); 1332 OSDMap response = CachedPostRequest(requestArgs);
1314 if (response["Success"].AsBoolean()) 1333 if (response["Success"].AsBoolean())
1315 { 1334 {
1316 return true; 1335 return true;
@@ -1321,8 +1340,50 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1321 return false; 1340 return false;
1322 } 1341 }
1323 } 1342 }
1324 #endregion 1343 #endregion
1325 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
1326 } 1387 }
1327 1388
1328} 1389}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index 8e7aa68..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
@@ -68,14 +69,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
68 private string m_groupReadKey = string.Empty; 69 private string m_groupReadKey = string.Empty;
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
73 // Used to track which agents are have dropped from a group chat session 74 private ExpiringCache<string, XmlRpcResponse> m_memoryCache;
74 // Should be reset per agent, on logon 75 private int m_cacheTimeout = 30;
75 // TODO: move this to Flotsam XmlRpc Service 76
76 // SessionID, List<AgentID> 77 // Used to track which agents are have dropped from a group chat session
77 private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>(); 78 // Should be reset per agent, on logon
78 private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>(); 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>>();
79 83
80 84
81 #region IRegionModuleBase Members 85 #region IRegionModuleBase Members
@@ -111,12 +115,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
111 return; 115 return;
112 } 116 }
113 117
114 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); 118 m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Initializing {0}", this.Name);
115 119
116 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); 120 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
117 if ((m_groupsServerURI == null) || 121 if ((m_groupsServerURI == null) ||
118 (m_groupsServerURI == string.Empty)) 122 (m_groupsServerURI == string.Empty))
119 { 123 {
120 m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]"); 124 m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]");
121 m_connectorEnabled = false; 125 m_connectorEnabled = false;
122 return; 126 return;
@@ -127,17 +131,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
127 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); 131 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
128 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); 132 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
129 133
130
131 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 }
132 144
133 // 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>();
134 m_connectorEnabled = true; 147 m_connectorEnabled = true;
135 } 148 }
136 } 149 }
137 150
138 public void Close() 151 public void Close()
139 { 152 {
140 m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name); 153 m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Closing {0}", this.Name);
141 } 154 }
142 155
143 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) 156 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -766,67 +779,67 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
766 779
767 780
768 781
769 #endregion 782 #endregion
770 783
771 #region GroupSessionTracking 784 #region GroupSessionTracking
772 785
773 public void ResetAgentGroupChatSessions(UUID agentID) 786 public void ResetAgentGroupChatSessions(UUID agentID)
774 { 787 {
775 foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values) 788 foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values)
776 { 789 {
777 agentList.Remove(agentID); 790 agentList.Remove(agentID);
778 } 791 }
779 } 792 }
780 793
781 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID) 794 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
782 { 795 {
783 // If we're tracking this group, and we can find them in the tracking, then they've been invited 796 // If we're tracking this group, and we can find them in the tracking, then they've been invited
784 return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID) 797 return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID)
785 && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID); 798 && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID);
786 } 799 }
787 800
788 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID) 801 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
789 { 802 {
790 // If we're tracking drops for this group, 803 // If we're tracking drops for this group,
791 // and we find them, well... then they've dropped 804 // and we find them, well... then they've dropped
792 return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID) 805 return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)
793 && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID); 806 && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID);
794 } 807 }
795 808
796 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID) 809 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
797 { 810 {
798 if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)) 811 if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
799 { 812 {
800 // If not in dropped list, add 813 // If not in dropped list, add
801 if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID)) 814 if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
802 { 815 {
803 m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID); 816 m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
804 } 817 }
805 } 818 }
806 } 819 }
807 820
808 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID) 821 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
809 { 822 {
810 // Add Session Status if it doesn't exist for this session 823 // Add Session Status if it doesn't exist for this session
811 CreateGroupChatSessionTracking(groupID); 824 CreateGroupChatSessionTracking(groupID);
812 825
813 // If nessesary, remove from dropped list 826 // If nessesary, remove from dropped list
814 if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID)) 827 if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
815 { 828 {
816 m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID); 829 m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
817 } 830 }
818 } 831 }
819 832
820 private void CreateGroupChatSessionTracking(UUID groupID) 833 private void CreateGroupChatSessionTracking(UUID groupID)
821 { 834 {
822 if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)) 835 if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
823 { 836 {
824 m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>()); 837 m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>());
825 m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>()); 838 m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>());
826 } 839 }
827 840
828 } 841 }
829 #endregion 842 #endregion
830 843
831 #region XmlRpcHashtableMarshalling 844 #region XmlRpcHashtableMarshalling
832 private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile) 845 private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile)
@@ -919,50 +932,84 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
919 /// </summary> 932 /// </summary>
920 private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param) 933 private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param)
921 { 934 {
922 string UserService; 935 XmlRpcResponse resp = null;
923 UUID SessionID; 936 string CacheKey = null;
924 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
925 param.Add("requestingAgentID", requestingAgentID.ToString());
926 param.Add("RequestingAgentUserService", UserService);
927 param.Add("RequestingSessionID", SessionID.ToString());
928
929 937
930 param.Add("ReadKey", m_groupReadKey); 938 // Only bother with the cache if it isn't disabled.
931 param.Add("WriteKey", m_groupWriteKey); 939 if (m_cacheTimeout > 0)
940 {
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 }
932 960
961 }
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());
933 971
934 IList parameters = new ArrayList();
935 parameters.Add(param);
936 972
937 ConfigurableKeepAliveXmlRpcRequest req; 973 param.Add("ReadKey", m_groupReadKey);
938 req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); 974 param.Add("WriteKey", m_groupWriteKey);
939 975
940 XmlRpcResponse resp = null;
941 976
942 try 977 IList parameters = new ArrayList();
943 { 978 parameters.Add(param);
944 resp = req.Send(m_groupsServerURI, 10000); 979
945 } 980 ConfigurableKeepAliveXmlRpcRequest req;
946 catch (Exception e) 981 req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
947 {
948
949 982
950 m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
951 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString());
952 983
953 foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine },StringSplitOptions.None)) 984 try
954 { 985 {
955 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine); 986 resp = req.Send(m_groupsServerURI, 10000);
956 } 987
988 if ((m_cacheTimeout > 0) && (CacheKey != null))
989 {
990 m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout));
991 }
957 992
958 foreach (string key in param.Keys) 993 }
994 catch (Exception e)
959 { 995 {
960 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;
961 } 1012 }
962
963 Hashtable respData = new Hashtable();
964 respData.Add("error", e.ToString());
965 return respData;
966 } 1013 }
967 1014
968 if (resp.Value is Hashtable) 1015 if (resp.Value is Hashtable)
@@ -976,21 +1023,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
976 return respData; 1023 return respData;
977 } 1024 }
978 1025
979 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());
980 1027
981 if (resp.Value is ArrayList) 1028 if (resp.Value is ArrayList)
982 { 1029 {
983 ArrayList al = (ArrayList)resp.Value; 1030 ArrayList al = (ArrayList)resp.Value;
984 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Contains {0} elements", al.Count); 1031 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Contains {0} elements", al.Count);
985 1032
986 foreach (object o in al) 1033 foreach (object o in al)
987 { 1034 {
988 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());
989 } 1036 }
990 } 1037 }
991 else 1038 else
992 { 1039 {
993 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Function returned: {0}", resp.Value.ToString()); 1040 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Function returned: {0}", resp.Value.ToString());
994 } 1041 }
995 1042
996 Hashtable error = new Hashtable(); 1043 Hashtable error = new Hashtable();
@@ -1000,16 +1047,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1000 1047
1001 private void LogRespDataToConsoleError(Hashtable respData) 1048 private void LogRespDataToConsoleError(Hashtable respData)
1002 { 1049 {
1003 m_log.Error("[XMLRPCGROUPDATA]: Error:"); 1050 m_log.Error("[XMLRPC-GROUPS-CONNECTOR]: Error:");
1004 1051
1005 foreach (string key in respData.Keys) 1052 foreach (string key in respData.Keys)
1006 { 1053 {
1007 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Key: {0}", key); 1054 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Key: {0}", key);
1008 1055
1009 string[] lines = respData[key].ToString().Split(new char[] { '\n' }); 1056 string[] lines = respData[key].ToString().Split(new char[] { '\n' });
1010 foreach (string line in lines) 1057 foreach (string line in lines)
1011 { 1058 {
1012 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0}", line); 1059 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", line);
1013 } 1060 }
1014 1061
1015 } 1062 }