aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs4
-rw-r--r--OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs3
-rw-r--r--OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs113
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs187
-rw-r--r--OpenSim/Services/Interfaces/IGridUserService.cs2
-rw-r--r--OpenSim/Services/UserAccountService/GridUserService.cs2
9 files changed, 189 insertions, 132 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
index 6c01927..7d2dc5a 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
72 { 72 {
73 m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); 73 m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
74 74
75 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); 75 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
76 } 76 }
77 77
78 public void OnNewClient(IClientAPI client) 78 public void OnNewClient(IClientAPI client)
@@ -109,7 +109,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
109 { 109 {
110 // TODO: grab the parcel ID from ILandModule 110 // TODO: grab the parcel ID from ILandModule
111 // and send that along 111 // and send that along
112 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); 112 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
113 } 113 }
114 114
115 } 115 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs
index d914a57..76e030f 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs
@@ -162,9 +162,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
162 return m_GridUserService.SetHome(userID, homeID, homePosition, homeLookAt); 162 return m_GridUserService.SetHome(userID, homeID, homePosition, homeLookAt);
163 } 163 }
164 164
165 public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 165 public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
166 { 166 {
167 return m_GridUserService.SetLastPosition(userID, regionID, lastPosition, lastLookAt); 167 return m_GridUserService.SetLastPosition(userID, sessionID, regionID, lastPosition, lastLookAt);
168 } 168 }
169 169
170 public GridUserInfo GetGridUserInfo(string userID) 170 public GridUserInfo GetGridUserInfo(string userID)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs
index e3e2e61..fb11e9a 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs
@@ -137,9 +137,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
137 return m_RemoteConnector.SetHome(userID, regionID, position, lookAt); 137 return m_RemoteConnector.SetHome(userID, regionID, position, lookAt);
138 } 138 }
139 139
140 public bool SetLastPosition(string userID, UUID regionID, Vector3 position, Vector3 lookAt) 140 public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
141 { 141 {
142 return m_RemoteConnector.SetLastPosition(userID, regionID, position, lookAt); 142 return m_RemoteConnector.SetLastPosition(userID, sessionID, regionID, position, lookAt);
143 } 143 }
144 144
145 public GridUserInfo GetGridUserInfo(string userID) 145 public GridUserInfo GetGridUserInfo(string userID)
diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
index f8fa429..b1e7eac 100644
--- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
@@ -156,6 +156,7 @@ namespace OpenSim.Server.Handlers.GridUser
156 byte[] SetPosition(Dictionary<string, object> request) 156 byte[] SetPosition(Dictionary<string, object> request)
157 { 157 {
158 string user = string.Empty; 158 string user = string.Empty;
159 UUID sessionID = UUID.Zero;
159 UUID region = UUID.Zero; 160 UUID region = UUID.Zero;
160 Vector3 position = new Vector3(128, 128, 70); 161 Vector3 position = new Vector3(128, 128, 70);
161 Vector3 look = Vector3.Zero; 162 Vector3 look = Vector3.Zero;
@@ -166,7 +167,7 @@ namespace OpenSim.Server.Handlers.GridUser
166 if (!UnpackArgs(request, out user, out region, out position, out look)) 167 if (!UnpackArgs(request, out user, out region, out position, out look))
167 return FailureResult(); 168 return FailureResult();
168 169
169 if (m_GridUserService.SetLastPosition(user, region, position, look)) 170 if (m_GridUserService.SetLastPosition(user, sessionID, region, position, look))
170 return SuccessResult(); 171 return SuccessResult();
171 172
172 return FailureResult(); 173 return FailureResult();
diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs
index b4500a5..f222e31 100644
--- a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs
+++ b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs
@@ -123,7 +123,7 @@ namespace OpenSim.Services.Connectors
123 return Set(sendData, userID, regionID, position, lookAt); 123 return Set(sendData, userID, regionID, position, lookAt);
124 } 124 }
125 125
126 public bool SetLastPosition(string userID, UUID regionID, Vector3 position, Vector3 lookAt) 126 public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
127 { 127 {
128 Dictionary<string, object> sendData = new Dictionary<string, object>(); 128 Dictionary<string, object> sendData = new Dictionary<string, object>();
129 //sendData["SCOPEID"] = scopeID.ToString(); 129 //sendData["SCOPEID"] = scopeID.ToString();
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
new file mode 100644
index 0000000..8cc5671
--- /dev/null
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
@@ -0,0 +1,113 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Services.Interfaces;
34using OpenMetaverse;
35using log4net;
36
37namespace OpenSim.Services.Connectors.SimianGrid
38{
39 public class SimianActivityDetector
40 {
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42
43 private IGridUserService m_GridUserService;
44 private Scene m_aScene;
45
46 public SimianActivityDetector(IGridUserService guservice)
47 {
48 m_GridUserService = guservice;
49 m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Started");
50 }
51
52 public void AddRegion(Scene scene)
53 {
54 // For now the only events we listen to are these
55 // But we could trigger the position update more often
56 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
57 scene.EventManager.OnNewClient += OnNewClient;
58 scene.EventManager.OnAvatarEnteringNewParcel += OnEnteringNewParcel;
59
60 if (m_aScene == null)
61 m_aScene = scene;
62 }
63
64 public void RemoveRegion(Scene scene)
65 {
66 scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent;
67 scene.EventManager.OnNewClient -= OnNewClient;
68 scene.EventManager.OnAvatarEnteringNewParcel -= OnEnteringNewParcel;
69 }
70
71 public void OnMakeRootAgent(ScenePresence sp)
72 {
73 m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
74 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
75 }
76
77 public void OnNewClient(IClientAPI client)
78 {
79 client.OnConnectionClosed += OnConnectionClose;
80 }
81
82 public void OnConnectionClose(IClientAPI client)
83 {
84 if (client.IsLoggingOut)
85 {
86 object sp = null;
87 Vector3 position = new Vector3(128, 128, 0);
88 Vector3 lookat = new Vector3(0, 1, 0);
89
90 if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
91 {
92 if (sp is ScenePresence)
93 {
94 if (((ScenePresence)sp).IsChildAgent)
95 return;
96
97 position = ((ScenePresence)sp).AbsolutePosition;
98 lookat = ((ScenePresence)sp).Lookat;
99 }
100 }
101
102 m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
103 m_GridUserService.LoggedOut(client.AgentId.ToString(), client.Scene.RegionInfo.RegionID, position, lookat);
104 }
105
106 }
107
108 void OnEnteringNewParcel(ScenePresence sp, int localLandID, UUID regionID)
109 {
110 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
111 }
112 }
113}
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
index b86c45c..ec9cf67 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
@@ -58,6 +58,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
58 MethodBase.GetCurrentMethod().DeclaringType); 58 MethodBase.GetCurrentMethod().DeclaringType);
59 59
60 private string m_serverUrl = String.Empty; 60 private string m_serverUrl = String.Empty;
61 private SimianActivityDetector m_activityDetector;
61 62
62 #region ISharedRegionModule 63 #region ISharedRegionModule
63 64
@@ -66,7 +67,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
66 public void PostInitialise() { } 67 public void PostInitialise() { }
67 public void Close() { } 68 public void Close() { }
68 69
69 public SimianPresenceServiceConnector() { } 70 public SimianPresenceServiceConnector() { m_activityDetector = new SimianActivityDetector(this); }
70 public string Name { get { return "SimianPresenceServiceConnector"; } } 71 public string Name { get { return "SimianPresenceServiceConnector"; } }
71 public void AddRegion(Scene scene) 72 public void AddRegion(Scene scene)
72 { 73 {
@@ -75,9 +76,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
75 scene.RegisterModuleInterface<IPresenceService>(this); 76 scene.RegisterModuleInterface<IPresenceService>(this);
76 scene.RegisterModuleInterface<IGridUserService>(this); 77 scene.RegisterModuleInterface<IGridUserService>(this);
77 78
78 scene.EventManager.OnMakeRootAgent += MakeRootAgentHandler; 79 m_activityDetector.AddRegion(scene);
79 scene.EventManager.OnNewClient += NewClientHandler;
80 scene.EventManager.OnSignificantClientMovement += SignificantClientMovementHandler;
81 80
82 LogoutRegionAgents(scene.RegionInfo.RegionID); 81 LogoutRegionAgents(scene.RegionInfo.RegionID);
83 } 82 }
@@ -89,9 +88,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
89 scene.UnregisterModuleInterface<IPresenceService>(this); 88 scene.UnregisterModuleInterface<IPresenceService>(this);
90 scene.UnregisterModuleInterface<IGridUserService>(this); 89 scene.UnregisterModuleInterface<IGridUserService>(this);
91 90
92 scene.EventManager.OnMakeRootAgent -= MakeRootAgentHandler; 91 m_activityDetector.RemoveRegion(scene);
93 scene.EventManager.OnNewClient -= NewClientHandler;
94 scene.EventManager.OnSignificantClientMovement -= SignificantClientMovementHandler;
95 92
96 LogoutRegionAgents(scene.RegionInfo.RegionID); 93 LogoutRegionAgents(scene.RegionInfo.RegionID);
97 } 94 }
@@ -193,29 +190,8 @@ namespace OpenSim.Services.Connectors.SimianGrid
193 190
194 public bool ReportAgent(UUID sessionID, UUID regionID) 191 public bool ReportAgent(UUID sessionID, UUID regionID)
195 { 192 {
196 return ReportAgent(sessionID, regionID, Vector3.Zero, Vector3.Zero); 193 // Not needed for SimianGrid
197 } 194 return true;
198
199 protected bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
200 {
201 //m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Updating session data for agent with sessionID " + sessionID);
202
203 NameValueCollection requestArgs = new NameValueCollection
204 {
205 { "RequestMethod", "UpdateSession" },
206 { "SessionID", sessionID.ToString() },
207 { "SceneID", regionID.ToString() },
208 { "ScenePosition", position.ToString() },
209 { "SceneLookAt", lookAt.ToString() }
210 };
211
212 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
213 bool success = response["Success"].AsBoolean();
214
215 if (!success)
216 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to update agent session " + sessionID + ": " + response["Message"].AsString());
217
218 return success;
219 } 195 }
220 196
221 public PresenceInfo GetAgent(UUID sessionID) 197 public PresenceInfo GetAgent(UUID sessionID)
@@ -274,14 +250,27 @@ namespace OpenSim.Services.Connectors.SimianGrid
274 250
275 public GridUserInfo LoggedIn(string userID) 251 public GridUserInfo LoggedIn(string userID)
276 { 252 {
277 // never implemented at the sim 253 // Never implemented at the sim
278 return null; 254 return null;
279 } 255 }
280 256
281 public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 257 public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
282 { 258 {
283 // Not needed for simian grid, event handler is doing it 259 // Save our last position as user data
284 return true; 260 NameValueCollection requestArgs = new NameValueCollection
261 {
262 { "RequestMethod", "AddUserData" },
263 { "UserID", userID.ToString() },
264 { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) }
265 };
266
267 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
268 bool success = response["Success"].AsBoolean();
269
270 if (!success)
271 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to set last location for " + userID + ": " + response["Message"].AsString());
272
273 return success;
285 } 274 }
286 275
287 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt) 276 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
@@ -304,10 +293,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
304 return success; 293 return success;
305 } 294 }
306 295
307 public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 296 public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
308 { 297 {
309 // Not needed for simian grid, presence detection is doing it 298 return UpdateSession(sessionID, regionID, lastPosition, lastLookAt);
310 return true;
311 } 299 }
312 300
313 public GridUserInfo GetGridUserInfo(string user) 301 public GridUserInfo GetGridUserInfo(string user)
@@ -334,54 +322,6 @@ namespace OpenSim.Services.Connectors.SimianGrid
334 322
335 #endregion 323 #endregion
336 324
337 #region Presence Detection
338
339 private void MakeRootAgentHandler(ScenePresence sp)
340 {
341 m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
342
343 ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
344 SetLastLocation(sp.UUID, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
345 }
346
347 private void NewClientHandler(IClientAPI client)
348 {
349 client.OnConnectionClosed += LogoutHandler;
350 }
351
352 private void SignificantClientMovementHandler(IClientAPI client)
353 {
354 ScenePresence sp;
355 if (client.Scene is Scene && ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out sp))
356 ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
357 }
358
359 private void LogoutHandler(IClientAPI client)
360 {
361 if (client.IsLoggingOut)
362 {
363 client.OnConnectionClosed -= LogoutHandler;
364
365 object obj;
366 if (client.Scene.TryGetScenePresence(client.AgentId, out obj) && obj is ScenePresence)
367 {
368 // The avatar is still in the scene, we can get the exact logout position
369 ScenePresence sp = (ScenePresence)obj;
370 SetLastLocation(client.AgentId, client.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
371 }
372 else
373 {
374 // The avatar was already removed from the scene, store LastLocation using the most recent session data
375 m_log.Warn("[PRESENCE]: " + client.Name + " has already been removed from the scene, storing approximate LastLocation");
376 SetLastLocation(client.SessionId);
377 }
378
379 LogoutAgent(client.SessionId);
380 }
381 }
382
383 #endregion Presence Detection
384
385 #region Helpers 325 #region Helpers
386 326
387 private OSDMap GetUserData(UUID userID) 327 private OSDMap GetUserData(UUID userID)
@@ -453,57 +393,60 @@ namespace OpenSim.Services.Connectors.SimianGrid
453 return presences; 393 return presences;
454 } 394 }
455 395
456 /// <summary> 396 private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
457 /// Fetch the last known avatar location with GetSession and persist it
458 /// as user data with AddUserData
459 /// </summary>
460 private bool SetLastLocation(UUID sessionID)
461 { 397 {
398 // Save our current location as session data
462 NameValueCollection requestArgs = new NameValueCollection 399 NameValueCollection requestArgs = new NameValueCollection
463 { 400 {
464 { "RequestMethod", "GetSession" }, 401 { "RequestMethod", "UpdateSession" },
465 { "SessionID", sessionID.ToString() } 402 { "SessionID", sessionID.ToString() },
403 { "SceneID", regionID.ToString() },
404 { "ScenePosition", lastPosition.ToString() },
405 { "SceneLookAt", lastLookAt.ToString() }
466 }; 406 };
467 407
468 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); 408 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
469 bool success = response["Success"].AsBoolean(); 409 bool success = response["Success"].AsBoolean();
470 410
471 if (success)
472 {
473 UUID userID = response["UserID"].AsUUID();
474 UUID sceneID = response["SceneID"].AsUUID();
475 Vector3 position = response["ScenePosition"].AsVector3();
476 Vector3 lookAt = response["SceneLookAt"].AsVector3();
477
478 return SetLastLocation(userID, sceneID, position, lookAt);
479 }
480 else
481 {
482 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve presence information for session " + sessionID +
483 " while saving last location: " + response["Message"].AsString());
484 }
485
486 return success;
487 }
488
489 private bool SetLastLocation(UUID userID, UUID sceneID, Vector3 position, Vector3 lookAt)
490 {
491 NameValueCollection requestArgs = new NameValueCollection
492 {
493 { "RequestMethod", "AddUserData" },
494 { "UserID", userID.ToString() },
495 { "LastLocation", SerializeLocation(sceneID, position, lookAt) }
496 };
497
498 OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
499 bool success = response["Success"].AsBoolean();
500
501 if (!success) 411 if (!success)
502 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to set last location for " + userID + ": " + response["Message"].AsString()); 412 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to update agent session " + sessionID + ": " + response["Message"].AsString());
503 413
504 return success; 414 return success;
505 } 415 }
506 416
417 ///// <summary>
418 ///// Fetch the last known avatar location with GetSession and persist it
419 ///// as user data with AddUserData
420 ///// </summary>
421 //private bool SetLastLocation(UUID sessionID)
422 //{
423 // NameValueCollection requestArgs = new NameValueCollection
424 // {
425 // { "RequestMethod", "GetSession" },
426 // { "SessionID", sessionID.ToString() }
427 // };
428
429 // OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
430 // bool success = response["Success"].AsBoolean();
431
432 // if (success)
433 // {
434 // UUID userID = response["UserID"].AsUUID();
435 // UUID sceneID = response["SceneID"].AsUUID();
436 // Vector3 position = response["ScenePosition"].AsVector3();
437 // Vector3 lookAt = response["SceneLookAt"].AsVector3();
438
439 // return SetLastLocation(userID, sceneID, position, lookAt);
440 // }
441 // else
442 // {
443 // m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve presence information for session " + sessionID +
444 // " while saving last location: " + response["Message"].AsString());
445 // }
446
447 // return success;
448 //}
449
507 private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse, OSDMap userResponse) 450 private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse, OSDMap userResponse)
508 { 451 {
509 if (sessionResponse == null) 452 if (sessionResponse == null)
diff --git a/OpenSim/Services/Interfaces/IGridUserService.cs b/OpenSim/Services/Interfaces/IGridUserService.cs
index e629dff..3d11b3e 100644
--- a/OpenSim/Services/Interfaces/IGridUserService.cs
+++ b/OpenSim/Services/Interfaces/IGridUserService.cs
@@ -108,7 +108,7 @@ namespace OpenSim.Services.Interfaces
108 bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt); 108 bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt);
109 109
110 bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt); 110 bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt);
111 bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt); 111 bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt);
112 112
113 GridUserInfo GetGridUserInfo(string userID); 113 GridUserInfo GetGridUserInfo(string userID);
114 } 114 }
diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs
index 697ba63..00a1ae2 100644
--- a/OpenSim/Services/UserAccountService/GridUserService.cs
+++ b/OpenSim/Services/UserAccountService/GridUserService.cs
@@ -139,7 +139,7 @@ namespace OpenSim.Services.UserAccountService
139 return m_Database.Store(d); 139 return m_Database.Store(d);
140 } 140 }
141 141
142 public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 142 public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
143 { 143 {
144 //m_log.DebugFormat("[Grid User Service]: SetLastPosition for {0}", userID); 144 //m_log.DebugFormat("[Grid User Service]: SetLastPosition for {0}", userID);
145 GridUserData d = m_Database.Get(userID); 145 GridUserData d = m_Database.Get(userID);