aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/SimianGrid
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Connectors/SimianGrid')
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs88
1 files changed, 82 insertions, 6 deletions
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
index c324272..e48b7de 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
51 /// message routing) to the SimianGrid backend 51 /// message routing) to the SimianGrid backend
52 /// </summary> 52 /// </summary>
53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
54 public class SimianPresenceServiceConnector : IPresenceService, ISharedRegionModule 54 public class SimianPresenceServiceConnector : IPresenceService, IGridUserService, ISharedRegionModule
55 { 55 {
56 private static readonly ILog m_log = 56 private static readonly ILog m_log =
57 LogManager.GetLogger( 57 LogManager.GetLogger(
@@ -73,6 +73,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
73 if (!String.IsNullOrEmpty(m_serverUrl)) 73 if (!String.IsNullOrEmpty(m_serverUrl))
74 { 74 {
75 scene.RegisterModuleInterface<IPresenceService>(this); 75 scene.RegisterModuleInterface<IPresenceService>(this);
76 scene.RegisterModuleInterface<IGridUserService>(this);
76 77
77 scene.EventManager.OnMakeRootAgent += MakeRootAgentHandler; 78 scene.EventManager.OnMakeRootAgent += MakeRootAgentHandler;
78 scene.EventManager.OnNewClient += NewClientHandler; 79 scene.EventManager.OnNewClient += NewClientHandler;
@@ -86,6 +87,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
86 if (!String.IsNullOrEmpty(m_serverUrl)) 87 if (!String.IsNullOrEmpty(m_serverUrl))
87 { 88 {
88 scene.UnregisterModuleInterface<IPresenceService>(this); 89 scene.UnregisterModuleInterface<IPresenceService>(this);
90 scene.UnregisterModuleInterface<IGridUserService>(this);
89 91
90 scene.EventManager.OnMakeRootAgent -= MakeRootAgentHandler; 92 scene.EventManager.OnMakeRootAgent -= MakeRootAgentHandler;
91 scene.EventManager.OnNewClient -= NewClientHandler; 93 scene.EventManager.OnNewClient -= NewClientHandler;
@@ -151,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
151 return success; 153 return success;
152 } 154 }
153 155
154 public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookAt) 156 public bool LogoutAgent(UUID sessionID)
155 { 157 {
156 m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID); 158 m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID);
157 159
@@ -189,7 +191,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
189 return success; 191 return success;
190 } 192 }
191 193
192 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) 194 public bool ReportAgent(UUID sessionID, UUID regionID)
195 {
196 return ReportAgent(sessionID, regionID, Vector3.Zero, Vector3.Zero);
197 }
198
199 protected bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
193 { 200 {
194 //m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Updating session data for agent with sessionID " + sessionID); 201 //m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Updating session data for agent with sessionID " + sessionID);
195 202
@@ -261,7 +268,23 @@ namespace OpenSim.Services.Connectors.SimianGrid
261 return presences.ToArray(); 268 return presences.ToArray();
262 } 269 }
263 270
264 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) 271 #endregion IPresenceService
272
273 #region IGridUserService
274
275 public GridUserInfo LoggedIn(string userID)
276 {
277 // never implemented at the sim
278 return null;
279 }
280
281 public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
282 {
283 // Not needed for simian grid, event handler is doing it
284 return true;
285 }
286
287 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
265 { 288 {
266 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID); 289 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID);
267 290
@@ -281,7 +304,35 @@ namespace OpenSim.Services.Connectors.SimianGrid
281 return success; 304 return success;
282 } 305 }
283 306
284 #endregion IPresenceService 307 public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
308 {
309 // Not needed for simian grid, presence detection is doing it
310 return true;
311 }
312
313 public GridUserInfo GetGridUserInfo(string user)
314 {
315 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user);
316
317 UUID userID = new UUID(user);
318 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID);
319
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);
329 else
330 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString());
331
332 return null;
333 }
334
335 #endregion
285 336
286 #region Presence Detection 337 #region Presence Detection
287 338
@@ -325,7 +376,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
325 SetLastLocation(client.SessionId); 376 SetLastLocation(client.SessionId);
326 } 377 }
327 378
328 LogoutAgent(client.SessionId, Vector3.Zero, Vector3.UnitX); 379 LogoutAgent(client.SessionId);
329 } 380 }
330 } 381 }
331 382
@@ -478,6 +529,31 @@ namespace OpenSim.Services.Connectors.SimianGrid
478 return info; 529 return info;
479 } 530 }
480 531
532 private GridUserInfo ResponseToGridUserInfo(OSDMap userResponse)
533 {
534 if (userResponse != null && userResponse["User"] is OSDMap)
535 {
536
537 GridUserInfo info = new GridUserInfo();
538
539 info.Online = true;
540 info.UserID = userResponse["UserID"].AsUUID().ToString();
541 info.LastRegionID = userResponse["SceneID"].AsUUID();
542 info.LastPosition = userResponse["ScenePosition"].AsVector3();
543 info.LastLookAt = userResponse["SceneLookAt"].AsVector3();
544
545 OSDMap user = (OSDMap)userResponse["User"];
546
547 info.Login = user["LastLoginDate"].AsDate();
548 info.Logout = user["LastLogoutDate"].AsDate();
549 DeserializeLocation(user["HomeLocation"].AsString(), out info.HomeRegionID, out info.HomePosition, out info.HomeLookAt);
550
551 return info;
552 }
553
554 return null;
555 }
556
481 private string SerializeLocation(UUID regionID, Vector3 position, Vector3 lookAt) 557 private string SerializeLocation(UUID regionID, Vector3 position, Vector3 lookAt)
482 { 558 {
483 return "{" + String.Format("\"SceneID\":\"{0}\",\"Position\":\"{1}\",\"LookAt\":\"{2}\"", regionID, position, lookAt) + "}"; 559 return "{" + String.Format("\"SceneID\":\"{0}\",\"Position\":\"{1}\",\"LookAt\":\"{2}\"", regionID, position, lookAt) + "}";