aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
diff options
context:
space:
mode:
authorunknown2010-05-20 11:51:57 -0700
committerunknown2010-05-20 11:51:57 -0700
commit59dec2f989474158c94a2383b150c25d132777aa (patch)
tree1452f96feca0a8531a7864522f2e796cc82ca288 /OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim into slimupd... (diff)
downloadopensim-SC_OLD-59dec2f989474158c94a2383b150c25d132777aa.zip
opensim-SC_OLD-59dec2f989474158c94a2383b150c25d132777aa.tar.gz
opensim-SC_OLD-59dec2f989474158c94a2383b150c25d132777aa.tar.bz2
opensim-SC_OLD-59dec2f989474158c94a2383b150c25d132777aa.tar.xz
* Added sessionID to IGridUserService.SetLastPosition(), as some connectors will want to track position against sessionID instead of userID
* Updated SimianPresenceServiceConnector to use the new LoggedOut/SetHome/etc methods and only update session position on parcel crossing
Diffstat (limited to 'OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs')
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs113
1 files changed, 113 insertions, 0 deletions
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}