aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs193
1 files changed, 83 insertions, 110 deletions
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
index 854bea4..7bb06fb 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
@@ -137,10 +137,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
137 userID, sessionID, secureSessionID); 137 userID, sessionID, secureSessionID);
138 138
139 NameValueCollection requestArgs = new NameValueCollection 139 NameValueCollection requestArgs = new NameValueCollection
140 { 140 {
141 { "RequestMethod", "AddSession" }, 141 { "RequestMethod", "AddSession" },
142 { "UserID", userID.ToString() } 142 { "UserID", userID.ToString() }
143 }; 143 };
144
144 if (sessionID != UUID.Zero) 145 if (sessionID != UUID.Zero)
145 { 146 {
146 requestArgs["SessionID"] = sessionID.ToString(); 147 requestArgs["SessionID"] = sessionID.ToString();
@@ -158,13 +159,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
158 159
159 public bool LogoutAgent(UUID sessionID) 160 public bool LogoutAgent(UUID sessionID)
160 { 161 {
161// m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID); 162 // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID);
162 163
163 NameValueCollection requestArgs = new NameValueCollection 164 NameValueCollection requestArgs = new NameValueCollection
164 { 165 {
165 { "RequestMethod", "RemoveSession" }, 166 { "RequestMethod", "RemoveSession" },
166 { "SessionID", sessionID.ToString() } 167 { "SessionID", sessionID.ToString() }
167 }; 168 };
168 169
169 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 170 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
170 bool success = response["Success"].AsBoolean(); 171 bool success = response["Success"].AsBoolean();
@@ -177,13 +178,13 @@ namespace OpenSim.Services.Connectors.SimianGrid
177 178
178 public bool LogoutRegionAgents(UUID regionID) 179 public bool LogoutRegionAgents(UUID regionID)
179 { 180 {
180// m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID); 181 // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID);
181 182
182 NameValueCollection requestArgs = new NameValueCollection 183 NameValueCollection requestArgs = new NameValueCollection
183 { 184 {
184 { "RequestMethod", "RemoveSessions" }, 185 { "RequestMethod", "RemoveSessions" },
185 { "SceneID", regionID.ToString() } 186 { "SceneID", regionID.ToString() }
186 }; 187 };
187 188
188 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 189 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
189 bool success = response["Success"].AsBoolean(); 190 bool success = response["Success"].AsBoolean();
@@ -202,49 +203,46 @@ namespace OpenSim.Services.Connectors.SimianGrid
202 203
203 public PresenceInfo GetAgent(UUID sessionID) 204 public PresenceInfo GetAgent(UUID sessionID)
204 { 205 {
205// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent with sessionID " + sessionID); 206 OSDMap sessionResponse = GetSessionDataFromSessionID(sessionID);
206 207 if (sessionResponse == null)
207 NameValueCollection requestArgs = new NameValueCollection
208 {
209 { "RequestMethod", "GetSession" },
210 { "SessionID", sessionID.ToString() }
211 };
212
213 OSDMap sessionResponse = WebUtil.PostToService(m_serverUrl, requestArgs);
214 if (sessionResponse["Success"].AsBoolean())
215 { 208 {
216 UUID userID = sessionResponse["UserID"].AsUUID(); 209 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session {0}: {1}",sessionID.ToString(),sessionResponse["Message"].AsString());
217 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); 210 return null;
218
219 requestArgs = new NameValueCollection
220 {
221 { "RequestMethod", "GetUser" },
222 { "UserID", userID.ToString() }
223 };
224
225 OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs);
226 if (userResponse["Success"].AsBoolean())
227 return ResponseToPresenceInfo(sessionResponse, userResponse);
228 else
229 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString());
230 } 211 }
231 else 212
213 UUID userID = sessionResponse["UserID"].AsUUID();
214 OSDMap userResponse = GetUserData(userID);
215 if (userResponse == null)
232 { 216 {
233 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session " + sessionID + ": " + sessionResponse["Message"].AsString()); 217 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}: {1}",userID.ToString(),userResponse["Message"].AsString());
218 return null;
234 } 219 }
235 220
236 return null; 221 return ResponseToPresenceInfo(sessionResponse);
237 } 222 }
238 223
239 public PresenceInfo[] GetAgents(string[] userIDs) 224 public PresenceInfo[] GetAgents(string[] userIDs)
240 { 225 {
241 List<PresenceInfo> presences = new List<PresenceInfo>(userIDs.Length); 226 List<PresenceInfo> presences = new List<PresenceInfo>();
242 227
243 for (int i = 0; i < userIDs.Length; i++) 228 NameValueCollection requestArgs = new NameValueCollection
229 {
230 { "RequestMethod", "GetSessions" },
231 { "UserIDList", String.Join(",",userIDs) }
232 };
233
234 OSDMap sessionListResponse = WebUtil.PostToService(m_serverUrl, requestArgs);
235 if (! sessionListResponse["Success"].AsBoolean())
244 { 236 {
245 UUID userID; 237 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve sessions: {0}",sessionListResponse["Message"].AsString());
246 if (UUID.TryParse(userIDs[i], out userID) && userID != UUID.Zero) 238 return null;
247 presences.AddRange(GetSessions(userID)); 239 }
240
241 OSDArray sessionList = sessionListResponse["Sessions"] as OSDArray;
242 for (int i = 0; i < sessionList.Count; i++)
243 {
244 OSDMap sessionInfo = sessionList[i] as OSDMap;
245 presences.Add(ResponseToPresenceInfo(sessionInfo));
248 } 246 }
249 247
250 return presences.ToArray(); 248 return presences.ToArray();
@@ -262,7 +260,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
262 260
263 public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 261 public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
264 { 262 {
265// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID); 263 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID);
266 264
267 // Remove the session to mark this user offline 265 // Remove the session to mark this user offline
268 if (!LogoutAgent(sessionID)) 266 if (!LogoutAgent(sessionID))
@@ -270,11 +268,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
270 268
271 // Save our last position as user data 269 // Save our last position as user data
272 NameValueCollection requestArgs = new NameValueCollection 270 NameValueCollection requestArgs = new NameValueCollection
273 { 271 {
274 { "RequestMethod", "AddUserData" }, 272 { "RequestMethod", "AddUserData" },
275 { "UserID", userID.ToString() }, 273 { "UserID", userID.ToString() },
276 { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) } 274 { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) }
277 }; 275 };
278 276
279 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 277 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
280 bool success = response["Success"].AsBoolean(); 278 bool success = response["Success"].AsBoolean();
@@ -287,14 +285,14 @@ namespace OpenSim.Services.Connectors.SimianGrid
287 285
288 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt) 286 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
289 { 287 {
290// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID); 288 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID);
291 289
292 NameValueCollection requestArgs = new NameValueCollection 290 NameValueCollection requestArgs = new NameValueCollection
293 { 291 {
294 { "RequestMethod", "AddUserData" }, 292 { "RequestMethod", "AddUserData" },
295 { "UserID", userID.ToString() }, 293 { "UserID", userID.ToString() },
296 { "HomeLocation", SerializeLocation(regionID, position, lookAt) } 294 { "HomeLocation", SerializeLocation(regionID, position, lookAt) }
297 }; 295 };
298 296
299 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 297 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
300 bool success = response["Success"].AsBoolean(); 298 bool success = response["Success"].AsBoolean();
@@ -312,23 +310,14 @@ namespace OpenSim.Services.Connectors.SimianGrid
312 310
313 public GridUserInfo GetGridUserInfo(string user) 311 public GridUserInfo GetGridUserInfo(string user)
314 { 312 {
315// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user); 313 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user);
316 314
317 UUID userID = new UUID(user); 315 UUID userID = new UUID(user);
318// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); 316 OSDMap userResponse = GetUserData(userID);
319 317 if (userResponse != null)
320 NameValueCollection requestArgs = new NameValueCollection
321 {
322 { "RequestMethod", "GetUser" },
323 { "UserID", userID.ToString() }
324 };
325
326 OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs);
327 if (userResponse["Success"].AsBoolean())
328 return ResponseToGridUserInfo(userResponse); 318 return ResponseToGridUserInfo(userResponse);
329 else
330 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString());
331 319
320 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}: {1}",userID,userResponse["Message"].AsString());
332 return null; 321 return null;
333 } 322 }
334 323
@@ -338,65 +327,49 @@ namespace OpenSim.Services.Connectors.SimianGrid
338 327
339 private OSDMap GetUserData(UUID userID) 328 private OSDMap GetUserData(UUID userID)
340 { 329 {
341// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); 330 // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID);
342 331
343 NameValueCollection requestArgs = new NameValueCollection 332 NameValueCollection requestArgs = new NameValueCollection
344 { 333 {
345 { "RequestMethod", "GetUser" }, 334 { "RequestMethod", "GetUser" },
346 { "UserID", userID.ToString() } 335 { "UserID", userID.ToString() }
347 }; 336 };
348 337
349 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 338 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
350 if (response["Success"].AsBoolean() && response["User"] is OSDMap) 339 if (response["Success"].AsBoolean() && response["User"] is OSDMap)
351 return response; 340 return response;
352 else
353 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + response["Message"].AsString());
354 341
342 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}; {1}",userID.ToString(),response["Message"].AsString());
355 return null; 343 return null;
356 } 344 }
357 345
358 private List<PresenceInfo> GetSessions(UUID userID) 346 private OSDMap GetSessionDataFromSessionID(UUID sessionID)
359 { 347 {
360 List<PresenceInfo> presences = new List<PresenceInfo>(1); 348 NameValueCollection requestArgs = new NameValueCollection
361
362 OSDMap userResponse = GetUserData(userID);
363 if (userResponse != null)
364 {
365// m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting sessions for " + userID);
366
367 NameValueCollection requestArgs = new NameValueCollection
368 { 349 {
369 { "RequestMethod", "GetSession" }, 350 { "RequestMethod", "GetSession" },
370 { "UserID", userID.ToString() } 351 { "SessionID", sessionID.ToString() }
371 }; 352 };
372 353
373 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 354 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
374 if (response["Success"].AsBoolean()) 355 if (response["Success"].AsBoolean())
375 { 356 return response;
376 PresenceInfo presence = ResponseToPresenceInfo(response, userResponse);
377 if (presence != null)
378 presences.Add(presence);
379 }
380// else
381// {
382// m_log.Debug("[SIMIAN PRESENCE CONNECTOR]: No session returned for " + userID + ": " + response["Message"].AsString());
383// }
384 }
385 357
386 return presences; 358 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session data for {0}; {1}",sessionID.ToString(),response["Message"].AsString());
359 return null;
387 } 360 }
388 361
389 private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 362 private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
390 { 363 {
391 // Save our current location as session data 364 // Save our current location as session data
392 NameValueCollection requestArgs = new NameValueCollection 365 NameValueCollection requestArgs = new NameValueCollection
393 { 366 {
394 { "RequestMethod", "UpdateSession" }, 367 { "RequestMethod", "UpdateSession" },
395 { "SessionID", sessionID.ToString() }, 368 { "SessionID", sessionID.ToString() },
396 { "SceneID", regionID.ToString() }, 369 { "SceneID", regionID.ToString() },
397 { "ScenePosition", lastPosition.ToString() }, 370 { "ScenePosition", lastPosition.ToString() },
398 { "SceneLookAt", lastLookAt.ToString() } 371 { "SceneLookAt", lastLookAt.ToString() }
399 }; 372 };
400 373
401 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 374 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
402 bool success = response["Success"].AsBoolean(); 375 bool success = response["Success"].AsBoolean();
@@ -407,7 +380,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
407 return success; 380 return success;
408 } 381 }
409 382
410 private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse, OSDMap userResponse) 383 private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse)
411 { 384 {
412 if (sessionResponse == null) 385 if (sessionResponse == null)
413 return null; 386 return null;