diff options
author | Justin Clark-Casey (justincc) | 2012-11-20 10:11:57 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-11-20 10:11:57 +0000 |
commit | ea65a64f7b1867780261c2a01a6323e057ddc097 (patch) | |
tree | e07abbcc4a3745d543f3aca4775a9e41a2b7cc82 /OpenSim/Region/CoreModules/ServiceConnectorsOut | |
parent | Add Iain Oliver to CONTRIBUTORS.txt (diff) | |
download | opensim-SC_OLD-ea65a64f7b1867780261c2a01a6323e057ddc097.zip opensim-SC_OLD-ea65a64f7b1867780261c2a01a6323e057ddc097.tar.gz opensim-SC_OLD-ea65a64f7b1867780261c2a01a6323e057ddc097.tar.bz2 opensim-SC_OLD-ea65a64f7b1867780261c2a01a6323e057ddc097.tar.xz |
refactor: Move common presence connector code into BasePresenceServiceConnector
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut')
4 files changed, 145 insertions, 193 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..c84518d --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/BasePresenceServiceConnector.cs | |||
@@ -0,0 +1,133 @@ | |||
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 | return m_PresenceService.GetAgents(userIDs); | ||
129 | } | ||
130 | |||
131 | #endregion | ||
132 | } | ||
133 | } \ 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 d8bed1b..db5c520 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs | |||
@@ -24,53 +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 Mono.Addins; | ||
40 | using Nini.Config; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence |
43 | { | 42 | { |
44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalPresenceServicesConnector")] | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalPresenceServicesConnector")] |
45 | public class LocalPresenceServicesConnector : ISharedRegionModule, IPresenceService | 44 | public class LocalPresenceServicesConnector : BasePresenceServiceConnector, ISharedRegionModule, IPresenceService |
46 | { | 45 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 47 | ||
49 | private bool m_Enabled = false; | ||
50 | |||
51 | private PresenceDetector m_PresenceDetector; | ||
52 | |||
53 | /// <summary> | ||
54 | /// Underlying presence service. Do not use directly. | ||
55 | /// </summary> | ||
56 | public IPresenceService m_PresenceService; | ||
57 | |||
58 | public LocalPresenceServicesConnector() | ||
59 | { | ||
60 | } | ||
61 | |||
62 | public LocalPresenceServicesConnector(IConfigSource source) | ||
63 | { | ||
64 | Initialise(source); | ||
65 | } | ||
66 | |||
67 | #region ISharedRegionModule | 48 | #region ISharedRegionModule |
68 | 49 | ||
69 | public Type ReplaceableInterface | ||
70 | { | ||
71 | get { return null; } | ||
72 | } | ||
73 | |||
74 | public string Name | 50 | public string Name |
75 | { | 51 | { |
76 | get { return "LocalPresenceServicesConnector"; } | 52 | get { return "LocalPresenceServicesConnector"; } |
@@ -121,81 +97,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | |||
121 | } | 97 | } |
122 | } | 98 | } |
123 | 99 | ||
124 | public void PostInitialise() | ||
125 | { | ||
126 | } | ||
127 | |||
128 | public void Close() | ||
129 | { | ||
130 | } | ||
131 | |||
132 | public void AddRegion(Scene scene) | ||
133 | { | ||
134 | if (!m_Enabled) | ||
135 | return; | ||
136 | |||
137 | // m_log.DebugFormat( | ||
138 | // "[LOCAL PRESENCE CONNECTOR]: Registering IPresenceService to scene {0}", scene.RegionInfo.RegionName); | ||
139 | |||
140 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
141 | m_PresenceDetector.AddRegion(scene); | ||
142 | |||
143 | m_log.InfoFormat("[LOCAL PRESENCE CONNECTOR]: Enabled local presence for region {0}", scene.RegionInfo.RegionName); | ||
144 | |||
145 | } | ||
146 | |||
147 | public void RemoveRegion(Scene scene) | ||
148 | { | ||
149 | if (!m_Enabled) | ||
150 | return; | ||
151 | |||
152 | m_PresenceDetector.RemoveRegion(scene); | ||
153 | } | ||
154 | |||
155 | public void RegionLoaded(Scene scene) | ||
156 | { | ||
157 | if (!m_Enabled) | ||
158 | return; | ||
159 | |||
160 | } | ||
161 | |||
162 | #endregion | 100 | #endregion |
163 | |||
164 | #region IPresenceService | ||
165 | |||
166 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
167 | { | ||
168 | m_log.Warn("[LOCAL PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
169 | return false; | ||
170 | } | ||
171 | |||
172 | public bool LogoutAgent(UUID sessionID) | ||
173 | { | ||
174 | return m_PresenceService.LogoutAgent(sessionID); | ||
175 | } | ||
176 | |||
177 | |||
178 | public bool LogoutRegionAgents(UUID regionID) | ||
179 | { | ||
180 | return m_PresenceService.LogoutRegionAgents(regionID); | ||
181 | } | ||
182 | |||
183 | public bool ReportAgent(UUID sessionID, UUID regionID) | ||
184 | { | ||
185 | return m_PresenceService.ReportAgent(sessionID, regionID); | ||
186 | } | ||
187 | |||
188 | public PresenceInfo GetAgent(UUID sessionID) | ||
189 | { | ||
190 | return m_PresenceService.GetAgent(sessionID); | ||
191 | } | ||
192 | |||
193 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
194 | { | ||
195 | return m_PresenceService.GetAgents(userIDs); | ||
196 | } | ||
197 | |||
198 | #endregion | ||
199 | |||
200 | } | 101 | } |
201 | } | 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 be73932..6ca5c28 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs | |||
@@ -43,22 +43,12 @@ using Nini.Config; | |||
43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence |
44 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemotePresenceServicesConnector")] | 45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemotePresenceServicesConnector")] |
46 | public class RemotePresenceServicesConnector : ISharedRegionModule, IPresenceService | 46 | public class RemotePresenceServicesConnector : BasePresenceServiceConnector, ISharedRegionModule |
47 | { | 47 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | #region ISharedRegionModule | 50 | #region ISharedRegionModule |
51 | 51 | ||
52 | private bool m_Enabled = false; | ||
53 | |||
54 | private PresenceDetector m_PresenceDetector; | ||
55 | private IPresenceService m_RemoteConnector; | ||
56 | |||
57 | public Type ReplaceableInterface | ||
58 | { | ||
59 | get { return null; } | ||
60 | } | ||
61 | |||
62 | public string Name | 52 | public string Name |
63 | { | 53 | { |
64 | get { return "RemotePresenceServicesConnector"; } | 54 | get { return "RemotePresenceServicesConnector"; } |
@@ -72,7 +62,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | |||
72 | string name = moduleConfig.GetString("PresenceServices", ""); | 62 | string name = moduleConfig.GetString("PresenceServices", ""); |
73 | if (name == Name) | 63 | if (name == Name) |
74 | { | 64 | { |
75 | m_RemoteConnector = new PresenceServicesConnector(source); | 65 | m_PresenceService = new PresenceServicesConnector(source); |
76 | 66 | ||
77 | m_Enabled = true; | 67 | m_Enabled = true; |
78 | 68 | ||
@@ -81,81 +71,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | |||
81 | m_log.Info("[REMOTE PRESENCE CONNECTOR]: Remote presence enabled"); | 71 | m_log.Info("[REMOTE PRESENCE CONNECTOR]: Remote presence enabled"); |
82 | } | 72 | } |
83 | } | 73 | } |
84 | |||
85 | } | ||
86 | |||
87 | public void PostInitialise() | ||
88 | { | ||
89 | } | ||
90 | |||
91 | public void Close() | ||
92 | { | ||
93 | } | ||
94 | |||
95 | public void AddRegion(Scene scene) | ||
96 | { | ||
97 | if (!m_Enabled) | ||
98 | return; | ||
99 | |||
100 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
101 | m_PresenceDetector.AddRegion(scene); | ||
102 | |||
103 | m_log.InfoFormat("[REMOTE PRESENCE CONNECTOR]: Enabled remote presence for region {0}", scene.RegionInfo.RegionName); | ||
104 | |||
105 | } | ||
106 | |||
107 | public void RemoveRegion(Scene scene) | ||
108 | { | ||
109 | if (!m_Enabled) | ||
110 | return; | ||
111 | |||
112 | m_PresenceDetector.RemoveRegion(scene); | ||
113 | } | ||
114 | |||
115 | public void RegionLoaded(Scene scene) | ||
116 | { | ||
117 | if (!m_Enabled) | ||
118 | return; | ||
119 | |||
120 | } | ||
121 | |||
122 | #endregion | ||
123 | |||
124 | #region IPresenceService | ||
125 | |||
126 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
127 | { | ||
128 | m_log.Warn("[REMOTE PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
129 | return false; | ||
130 | } | ||
131 | |||
132 | public bool LogoutAgent(UUID sessionID) | ||
133 | { | ||
134 | return m_RemoteConnector.LogoutAgent(sessionID); | ||
135 | } | ||
136 | |||
137 | |||
138 | public bool LogoutRegionAgents(UUID regionID) | ||
139 | { | ||
140 | return m_RemoteConnector.LogoutRegionAgents(regionID); | ||
141 | } | ||
142 | |||
143 | public bool ReportAgent(UUID sessionID, UUID regionID) | ||
144 | { | ||
145 | return m_RemoteConnector.ReportAgent(sessionID, regionID); | ||
146 | } | ||
147 | |||
148 | public PresenceInfo GetAgent(UUID sessionID) | ||
149 | { | ||
150 | return m_RemoteConnector.GetAgent(sessionID); | ||
151 | } | ||
152 | |||
153 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
154 | { | ||
155 | return m_RemoteConnector.GetAgents(userIDs); | ||
156 | } | 74 | } |
157 | 75 | ||
158 | #endregion | 76 | #endregion |
159 | |||
160 | } | 77 | } |
161 | } | 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..32e47f9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs | |||
@@ -56,7 +56,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests | |||
56 | config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); | 56 | config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); |
57 | config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); | 57 | config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); |
58 | 58 | ||
59 | m_LocalConnector = new LocalPresenceServicesConnector(config); | 59 | m_LocalConnector = new LocalPresenceServicesConnector(); |
60 | m_LocalConnector.Initialise(config); | ||
60 | 61 | ||
61 | // Let's stick in a test presence | 62 | // Let's stick in a test presence |
62 | m_LocalConnector.m_PresenceService.LoginAgent(UUID.Zero.ToString(), UUID.Zero, UUID.Zero); | 63 | m_LocalConnector.m_PresenceService.LoginAgent(UUID.Zero.ToString(), UUID.Zero, UUID.Zero); |