diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence')
4 files changed, 153 insertions, 194 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/BasePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/BasePresenceServiceConnector.cs new file mode 100644 index 0000000..fdbe10a --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/BasePresenceServiceConnector.cs | |||
@@ -0,0 +1,137 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Mono.Addins; | ||
33 | using Nini.Config; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | using OpenSim.Server.Base; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
42 | { | ||
43 | public class BasePresenceServiceConnector : IPresenceService | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | protected bool m_Enabled; | ||
48 | |||
49 | protected PresenceDetector m_PresenceDetector; | ||
50 | |||
51 | /// <summary> | ||
52 | /// Underlying presence service. Do not use directly. | ||
53 | /// </summary> | ||
54 | public IPresenceService m_PresenceService; | ||
55 | |||
56 | public Type ReplaceableInterface | ||
57 | { | ||
58 | get { return null; } | ||
59 | } | ||
60 | |||
61 | public void AddRegion(Scene scene) | ||
62 | { | ||
63 | if (!m_Enabled) | ||
64 | return; | ||
65 | |||
66 | // m_log.DebugFormat( | ||
67 | // "[LOCAL PRESENCE CONNECTOR]: Registering IPresenceService to scene {0}", scene.RegionInfo.RegionName); | ||
68 | |||
69 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
70 | m_PresenceDetector.AddRegion(scene); | ||
71 | |||
72 | m_log.InfoFormat("[BASE PRESENCE SERVICE CONNECTOR]: Enabled for region {0}", scene.Name); | ||
73 | } | ||
74 | |||
75 | public void RemoveRegion(Scene scene) | ||
76 | { | ||
77 | if (!m_Enabled) | ||
78 | return; | ||
79 | |||
80 | m_PresenceDetector.RemoveRegion(scene); | ||
81 | } | ||
82 | |||
83 | public void RegionLoaded(Scene scene) | ||
84 | { | ||
85 | if (!m_Enabled) | ||
86 | return; | ||
87 | |||
88 | } | ||
89 | |||
90 | public void PostInitialise() | ||
91 | { | ||
92 | } | ||
93 | |||
94 | public void Close() | ||
95 | { | ||
96 | } | ||
97 | |||
98 | #region IPresenceService | ||
99 | |||
100 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
101 | { | ||
102 | m_log.Warn("[BASE PRESENCE SERVICE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
103 | return false; | ||
104 | } | ||
105 | |||
106 | public bool LogoutAgent(UUID sessionID) | ||
107 | { | ||
108 | return m_PresenceService.LogoutAgent(sessionID); | ||
109 | } | ||
110 | |||
111 | public bool LogoutRegionAgents(UUID regionID) | ||
112 | { | ||
113 | return m_PresenceService.LogoutRegionAgents(regionID); | ||
114 | } | ||
115 | |||
116 | public bool ReportAgent(UUID sessionID, UUID regionID) | ||
117 | { | ||
118 | return m_PresenceService.ReportAgent(sessionID, regionID); | ||
119 | } | ||
120 | |||
121 | public PresenceInfo GetAgent(UUID sessionID) | ||
122 | { | ||
123 | return m_PresenceService.GetAgent(sessionID); | ||
124 | } | ||
125 | |||
126 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
127 | { | ||
128 | // Don't bother potentially making a useless network call if we not going to ask for any users anyway. | ||
129 | if (userIDs.Length == 0) | ||
130 | return new PresenceInfo[0]; | ||
131 | |||
132 | return m_PresenceService.GetAgents(userIDs); | ||
133 | } | ||
134 | |||
135 | #endregion | ||
136 | } | ||
137 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs index 49dd633..db5c520 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs | |||
@@ -24,51 +24,29 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | |||
27 | using System; | 28 | using System; |
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | 31 | using log4net; | |
32 | using Mono.Addins; | ||
33 | using Nini.Config; | ||
34 | using OpenMetaverse; | ||
31 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
32 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
33 | using OpenSim.Server.Base; | 37 | using OpenSim.Server.Base; |
34 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
35 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | 39 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; |
36 | 40 | ||
37 | using OpenMetaverse; | ||
38 | using log4net; | ||
39 | using Nini.Config; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence |
42 | { | 42 | { |
43 | public class LocalPresenceServicesConnector : ISharedRegionModule, IPresenceService | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalPresenceServicesConnector")] |
44 | public class LocalPresenceServicesConnector : BasePresenceServiceConnector, ISharedRegionModule, IPresenceService | ||
44 | { | 45 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 47 | ||
47 | private bool m_Enabled = false; | ||
48 | |||
49 | private PresenceDetector m_PresenceDetector; | ||
50 | |||
51 | /// <summary> | ||
52 | /// Underlying presence service. Do not use directly. | ||
53 | /// </summary> | ||
54 | public IPresenceService m_PresenceService; | ||
55 | |||
56 | public LocalPresenceServicesConnector() | ||
57 | { | ||
58 | } | ||
59 | |||
60 | public LocalPresenceServicesConnector(IConfigSource source) | ||
61 | { | ||
62 | Initialise(source); | ||
63 | } | ||
64 | |||
65 | #region ISharedRegionModule | 48 | #region ISharedRegionModule |
66 | 49 | ||
67 | public Type ReplaceableInterface | ||
68 | { | ||
69 | get { return null; } | ||
70 | } | ||
71 | |||
72 | public string Name | 50 | public string Name |
73 | { | 51 | { |
74 | get { return "LocalPresenceServicesConnector"; } | 52 | get { return "LocalPresenceServicesConnector"; } |
@@ -119,81 +97,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | |||
119 | } | 97 | } |
120 | } | 98 | } |
121 | 99 | ||
122 | public void PostInitialise() | ||
123 | { | ||
124 | } | ||
125 | |||
126 | public void Close() | ||
127 | { | ||
128 | } | ||
129 | |||
130 | public void AddRegion(Scene scene) | ||
131 | { | ||
132 | if (!m_Enabled) | ||
133 | return; | ||
134 | |||
135 | // m_log.DebugFormat( | ||
136 | // "[LOCAL PRESENCE CONNECTOR]: Registering IPresenceService to scene {0}", scene.RegionInfo.RegionName); | ||
137 | |||
138 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
139 | m_PresenceDetector.AddRegion(scene); | ||
140 | |||
141 | m_log.InfoFormat("[LOCAL PRESENCE CONNECTOR]: Enabled local presence for region {0}", scene.RegionInfo.RegionName); | ||
142 | |||
143 | } | ||
144 | |||
145 | public void RemoveRegion(Scene scene) | ||
146 | { | ||
147 | if (!m_Enabled) | ||
148 | return; | ||
149 | |||
150 | m_PresenceDetector.RemoveRegion(scene); | ||
151 | } | ||
152 | |||
153 | public void RegionLoaded(Scene scene) | ||
154 | { | ||
155 | if (!m_Enabled) | ||
156 | return; | ||
157 | |||
158 | } | ||
159 | |||
160 | #endregion | ||
161 | |||
162 | #region IPresenceService | ||
163 | |||
164 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
165 | { | ||
166 | m_log.Warn("[LOCAL PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
167 | return false; | ||
168 | } | ||
169 | |||
170 | public bool LogoutAgent(UUID sessionID) | ||
171 | { | ||
172 | return m_PresenceService.LogoutAgent(sessionID); | ||
173 | } | ||
174 | |||
175 | |||
176 | public bool LogoutRegionAgents(UUID regionID) | ||
177 | { | ||
178 | return m_PresenceService.LogoutRegionAgents(regionID); | ||
179 | } | ||
180 | |||
181 | public bool ReportAgent(UUID sessionID, UUID regionID) | ||
182 | { | ||
183 | return m_PresenceService.ReportAgent(sessionID, regionID); | ||
184 | } | ||
185 | |||
186 | public PresenceInfo GetAgent(UUID sessionID) | ||
187 | { | ||
188 | return m_PresenceService.GetAgent(sessionID); | ||
189 | } | ||
190 | |||
191 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
192 | { | ||
193 | return m_PresenceService.GetAgents(userIDs); | ||
194 | } | ||
195 | |||
196 | #endregion | 100 | #endregion |
197 | |||
198 | } | 101 | } |
199 | } | 102 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs index bf4e9ab..6ca5c28 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs | |||
@@ -37,26 +37,18 @@ using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | |||
37 | 37 | ||
38 | using OpenMetaverse; | 38 | using OpenMetaverse; |
39 | using log4net; | 39 | using log4net; |
40 | using Mono.Addins; | ||
40 | using Nini.Config; | 41 | using Nini.Config; |
41 | 42 | ||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence |
43 | { | 44 | { |
44 | public class RemotePresenceServicesConnector : ISharedRegionModule, IPresenceService | 45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemotePresenceServicesConnector")] |
46 | public class RemotePresenceServicesConnector : BasePresenceServiceConnector, ISharedRegionModule | ||
45 | { | 47 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 49 | ||
48 | #region ISharedRegionModule | 50 | #region ISharedRegionModule |
49 | 51 | ||
50 | private bool m_Enabled = false; | ||
51 | |||
52 | private PresenceDetector m_PresenceDetector; | ||
53 | private IPresenceService m_RemoteConnector; | ||
54 | |||
55 | public Type ReplaceableInterface | ||
56 | { | ||
57 | get { return null; } | ||
58 | } | ||
59 | |||
60 | public string Name | 52 | public string Name |
61 | { | 53 | { |
62 | get { return "RemotePresenceServicesConnector"; } | 54 | get { return "RemotePresenceServicesConnector"; } |
@@ -70,7 +62,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | |||
70 | string name = moduleConfig.GetString("PresenceServices", ""); | 62 | string name = moduleConfig.GetString("PresenceServices", ""); |
71 | if (name == Name) | 63 | if (name == Name) |
72 | { | 64 | { |
73 | m_RemoteConnector = new PresenceServicesConnector(source); | 65 | m_PresenceService = new PresenceServicesConnector(source); |
74 | 66 | ||
75 | m_Enabled = true; | 67 | m_Enabled = true; |
76 | 68 | ||
@@ -79,81 +71,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | |||
79 | m_log.Info("[REMOTE PRESENCE CONNECTOR]: Remote presence enabled"); | 71 | m_log.Info("[REMOTE PRESENCE CONNECTOR]: Remote presence enabled"); |
80 | } | 72 | } |
81 | } | 73 | } |
82 | |||
83 | } | ||
84 | |||
85 | public void PostInitialise() | ||
86 | { | ||
87 | } | ||
88 | |||
89 | public void Close() | ||
90 | { | ||
91 | } | ||
92 | |||
93 | public void AddRegion(Scene scene) | ||
94 | { | ||
95 | if (!m_Enabled) | ||
96 | return; | ||
97 | |||
98 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
99 | m_PresenceDetector.AddRegion(scene); | ||
100 | |||
101 | m_log.InfoFormat("[REMOTE PRESENCE CONNECTOR]: Enabled remote presence for region {0}", scene.RegionInfo.RegionName); | ||
102 | |||
103 | } | ||
104 | |||
105 | public void RemoveRegion(Scene scene) | ||
106 | { | ||
107 | if (!m_Enabled) | ||
108 | return; | ||
109 | |||
110 | m_PresenceDetector.RemoveRegion(scene); | ||
111 | } | ||
112 | |||
113 | public void RegionLoaded(Scene scene) | ||
114 | { | ||
115 | if (!m_Enabled) | ||
116 | return; | ||
117 | |||
118 | } | ||
119 | |||
120 | #endregion | ||
121 | |||
122 | #region IPresenceService | ||
123 | |||
124 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
125 | { | ||
126 | m_log.Warn("[REMOTE PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
127 | return false; | ||
128 | } | ||
129 | |||
130 | public bool LogoutAgent(UUID sessionID) | ||
131 | { | ||
132 | return m_RemoteConnector.LogoutAgent(sessionID); | ||
133 | } | ||
134 | |||
135 | |||
136 | public bool LogoutRegionAgents(UUID regionID) | ||
137 | { | ||
138 | return m_RemoteConnector.LogoutRegionAgents(regionID); | ||
139 | } | ||
140 | |||
141 | public bool ReportAgent(UUID sessionID, UUID regionID) | ||
142 | { | ||
143 | return m_RemoteConnector.ReportAgent(sessionID, regionID); | ||
144 | } | ||
145 | |||
146 | public PresenceInfo GetAgent(UUID sessionID) | ||
147 | { | ||
148 | return m_RemoteConnector.GetAgent(sessionID); | ||
149 | } | ||
150 | |||
151 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
152 | { | ||
153 | return m_RemoteConnector.GetAgents(userIDs); | ||
154 | } | 74 | } |
155 | 75 | ||
156 | #endregion | 76 | #endregion |
157 | |||
158 | } | 77 | } |
159 | } | 78 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs index 4556df3..7e365ca 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs | |||
@@ -35,7 +35,6 @@ using NUnit.Framework; | |||
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using Nini.Config; | 37 | using Nini.Config; |
38 | |||
39 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; | 38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; |
40 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
41 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | 40 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; |
@@ -44,7 +43,7 @@ using OpenSim.Tests.Common; | |||
44 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests |
45 | { | 44 | { |
46 | [TestFixture] | 45 | [TestFixture] |
47 | public class PresenceConnectorsTests | 46 | public class PresenceConnectorsTests : OpenSimTestCase |
48 | { | 47 | { |
49 | LocalPresenceServicesConnector m_LocalConnector; | 48 | LocalPresenceServicesConnector m_LocalConnector; |
50 | private void SetUp() | 49 | private void SetUp() |
@@ -56,7 +55,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests | |||
56 | config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); | 55 | config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); |
57 | config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); | 56 | config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); |
58 | 57 | ||
59 | m_LocalConnector = new LocalPresenceServicesConnector(config); | 58 | m_LocalConnector = new LocalPresenceServicesConnector(); |
59 | m_LocalConnector.Initialise(config); | ||
60 | 60 | ||
61 | // Let's stick in a test presence | 61 | // Let's stick in a test presence |
62 | m_LocalConnector.m_PresenceService.LoginAgent(UUID.Zero.ToString(), UUID.Zero, UUID.Zero); | 62 | m_LocalConnector.m_PresenceService.LoginAgent(UUID.Zero.ToString(), UUID.Zero, UUID.Zero); |