aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
diff options
context:
space:
mode:
authorMelanie2010-05-06 16:38:23 +0100
committerMelanie2010-05-06 16:38:23 +0100
commit69d0201d4c3c62cda339eda35c15978837a7e2a3 (patch)
treec1693e6835c109234d5bdfa8c220b8e0b7832054 /OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
parentMerge branch 'master' into careminster-presence-refactor (diff)
downloadopensim-SC-69d0201d4c3c62cda339eda35c15978837a7e2a3.zip
opensim-SC-69d0201d4c3c62cda339eda35c15978837a7e2a3.tar.gz
opensim-SC-69d0201d4c3c62cda339eda35c15978837a7e2a3.tar.bz2
opensim-SC-69d0201d4c3c62cda339eda35c15978837a7e2a3.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 '')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs142
1 files changed, 127 insertions, 15 deletions
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}