aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorDiva Canto2009-12-27 08:38:05 -0800
committerDiva Canto2009-12-27 08:38:05 -0800
commitad8ee180900b83954718178be916f1278a30f46a (patch)
treeef5a7096cc9f892ab921a3897c2abb5e3c7e2e8e /OpenSim/Region/CoreModules
parentChange the signature of the forms requester data in preparation to getting (diff)
downloadopensim-SC-ad8ee180900b83954718178be916f1278a30f46a.zip
opensim-SC-ad8ee180900b83954718178be916f1278a30f46a.tar.gz
opensim-SC-ad8ee180900b83954718178be916f1278a30f46a.tar.bz2
opensim-SC-ad8ee180900b83954718178be916f1278a30f46a.tar.xz
First pass at the local connector for presence. No cache yet. Just the connector to the local service and a presence detector object.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs187
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs79
2 files changed, 266 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs
new file mode 100644
index 0000000..0012f0a
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs
@@ -0,0 +1,187 @@
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 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30
31using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Server.Base;
34using OpenSim.Services.Interfaces;
35using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
36
37using OpenMetaverse;
38using log4net;
39using Nini.Config;
40
41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
42{
43 public class LocalPresenceServiceConnector : ISharedRegionModule, IPresenceService
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 #region ISharedRegionModule
48
49 private bool m_Enabled = false;
50 private bool m_Initialized = false;
51
52 private PresenceDetector m_PresenceDetector;
53 private IPresenceService m_PresenceService;
54
55 public Type ReplaceableInterface
56 {
57 get { return null; }
58 }
59
60 public string Name
61 {
62 get { return "LocalPresenceServiceConnector"; }
63 }
64
65 public void Initialise(IConfigSource source)
66 {
67 IConfig moduleConfig = source.Configs["Modules"];
68 if (moduleConfig != null)
69 {
70 string name = moduleConfig.GetString("PresenceServices", "");
71 if (name == Name)
72 {
73 IConfig inventoryConfig = source.Configs["PresenceService"];
74 if (inventoryConfig == null)
75 {
76 m_log.Error("[LOCAL PRESENCE CONNECTOR]: PresenceService missing from OpenSim.ini");
77 return;
78 }
79
80 string serviceDll = inventoryConfig.GetString("LocalServiceModule", String.Empty);
81
82 if (serviceDll == String.Empty)
83 {
84 m_log.Error("[LOCAL PRESENCE CONNECTOR]: No LocalServiceModule named in section InventoryService");
85 return;
86 }
87
88 Object[] args = new Object[] { source };
89 m_log.DebugFormat("[LOCAL PRESENCE CONNECTOR]: Service dll = {0}", serviceDll);
90
91 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(serviceDll, args);
92
93 if (m_PresenceService == null)
94 {
95 m_log.Error("[LOCAL PRESENCE CONNECTOR]: Can't load presence service");
96 //return;
97 throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
98 }
99
100 //Init(source);
101
102 m_PresenceDetector = new PresenceDetector(this);
103
104 m_Enabled = true;
105 m_log.Info("[LOCAL PRESENCE CONNECTOR]: Local presence connector enabled");
106 }
107 }
108 }
109
110 public void PostInitialise()
111 {
112 }
113
114 public void Close()
115 {
116 }
117
118 public void AddRegion(Scene scene)
119 {
120 if (!m_Enabled)
121 return;
122
123 // m_log.DebugFormat(
124 // "[LOCAL PRESENCE CONNECTOR]: Registering IPresenceService to scene {0}", scene.RegionInfo.RegionName);
125
126 scene.RegisterModuleInterface<IPresenceService>(this);
127 m_PresenceDetector.AddRegion(scene);
128
129 m_log.InfoFormat("[LOCAL PRESENCE CONNECTOR]: Enabled local presence for region {0}", scene.RegionInfo.RegionName);
130
131 }
132
133 public void RemoveRegion(Scene scene)
134 {
135 if (!m_Enabled)
136 return;
137
138 m_PresenceDetector.RemoveRegion(scene);
139 }
140
141 public void RegionLoaded(Scene scene)
142 {
143 if (!m_Enabled)
144 return;
145
146 }
147
148 #endregion
149
150 #region IPresenceService
151
152 public bool LoginAgent(UUID principalID, UUID sessionID, UUID secureSessionID)
153 {
154 m_log.Warn("[LOCAL PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators");
155 return false;
156 }
157
158 public bool LogoutAgent(UUID sessionID)
159 {
160 return m_PresenceService.LogoutAgent(sessionID);
161 }
162
163
164 public bool LogoutRegionAgents(UUID regionID)
165 {
166 return m_PresenceService.LogoutRegionAgents(regionID);
167 }
168
169 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
170 {
171 return m_PresenceService.ReportAgent(sessionID, regionID, position, lookAt);
172 }
173
174 public PresenceInfo GetAgent(UUID sessionID)
175 {
176 return m_PresenceService.GetAgent(sessionID);
177 }
178
179 public PresenceInfo[] GetAgents(UUID[] principalIDs)
180 {
181 return m_PresenceService.GetAgents(principalIDs);
182 }
183
184 #endregion
185
186 }
187}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
new file mode 100644
index 0000000..150728f
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
@@ -0,0 +1,79 @@
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 */
27using System;
28using System.Collections.Generic;
29
30using OpenSim.Framework;
31using OpenSim.Region.Framework.Scenes;
32using OpenSim.Services.Interfaces;
33
34using OpenMetaverse;
35
36namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
37{
38 public class PresenceDetector
39 {
40 private IPresenceService m_PresenceService;
41
42 public PresenceDetector(IPresenceService presenceservice)
43 {
44 m_PresenceService = presenceservice;
45 }
46
47 public void AddRegion(Scene scene)
48 {
49 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
50 scene.EventManager.OnNewClient += OnNewClient;
51
52 m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID);
53 }
54
55 public void RemoveRegion(Scene scene)
56 {
57 scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent;
58 scene.EventManager.OnNewClient -= OnNewClient;
59
60 m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID);
61 }
62
63 public void OnMakeRootAgent(ScenePresence sp)
64 {
65 m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
66 }
67
68 public void OnNewClient(IClientAPI client)
69 {
70 client.OnLogout += OnLogout;
71 }
72
73 public void OnLogout(IClientAPI client)
74 {
75 client.OnLogout -= OnLogout;
76 m_PresenceService.LogoutAgent(client.SessionId);
77 }
78 }
79}