diff options
author | BlueWall | 2014-07-30 11:19:34 -0400 |
---|---|---|
committer | BlueWall | 2014-07-30 11:24:39 -0400 |
commit | e0d8f42e6be70974c1cdbf6ba3ff80c2eea7294d (patch) | |
tree | 7c84f3b616b287fc26d44f04f10201d5c3c06af4 /OpenSim/Region | |
parent | In TerrainModule, lock m_perClientPatchUpdates when removing entries. (diff) | |
download | opensim-SC_OLD-e0d8f42e6be70974c1cdbf6ba3ff80c2eea7294d.zip opensim-SC_OLD-e0d8f42e6be70974c1cdbf6ba3ff80c2eea7294d.tar.gz opensim-SC_OLD-e0d8f42e6be70974c1cdbf6ba3ff80c2eea7294d.tar.bz2 opensim-SC_OLD-e0d8f42e6be70974c1cdbf6ba3ff80c2eea7294d.tar.xz |
Simulator Extra Features Service
Provide a means for regions to fetch extra features supported by modern viewers from a central location
.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | 74 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/LocalGridFeaturesServiceInConnector.cs | 129 |
2 files changed, 194 insertions, 9 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index e4d8a20..587cb70 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | |||
@@ -56,13 +56,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
56 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimulatorFeaturesModule")] | 56 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimulatorFeaturesModule")] |
57 | public class SimulatorFeaturesModule : ISharedRegionModule, ISimulatorFeaturesModule | 57 | public class SimulatorFeaturesModule : ISharedRegionModule, ISimulatorFeaturesModule |
58 | { | 58 | { |
59 | // private static readonly ILog m_log = | 59 | private static readonly ILog m_log = |
60 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 60 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
61 | 61 | ||
62 | public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest; | 62 | public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest; |
63 | 63 | ||
64 | private Scene m_scene; | 64 | private Scene m_scene; |
65 | 65 | ||
66 | bool m_AllowOverride = true; | ||
67 | |||
66 | /// <summary> | 68 | /// <summary> |
67 | /// Simulator features | 69 | /// Simulator features |
68 | /// </summary> | 70 | /// </summary> |
@@ -75,8 +77,15 @@ namespace OpenSim.Region.ClientStack.Linden | |||
75 | 77 | ||
76 | public void Initialise(IConfigSource source) | 78 | public void Initialise(IConfigSource source) |
77 | { | 79 | { |
78 | IConfig config = source.Configs["SimulatorFeatures"]; | 80 | IConfig config = source.Configs ["SimulatorFeatures"]; |
79 | if (config != null) | 81 | string featuresURI = config.GetString ("ExtraFeaturesServiceURI", string.Empty); |
82 | if (string.IsNullOrEmpty (featuresURI)) { | ||
83 | m_log.Info ("ExtraFeaturesServiceURI is undefined. The grid's ExtraFeatures will not be available to regions in this instnace."); | ||
84 | } else { | ||
85 | GetGridExtraFeatures(featuresURI); | ||
86 | } | ||
87 | |||
88 | if (config != null && m_AllowOverride == true) | ||
80 | { | 89 | { |
81 | m_SearchURL = config.GetString("SearchServerURI", string.Empty); | 90 | m_SearchURL = config.GetString("SearchServerURI", string.Empty); |
82 | 91 | ||
@@ -126,6 +135,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
126 | /// </remarks> | 135 | /// </remarks> |
127 | private void AddDefaultFeatures() | 136 | private void AddDefaultFeatures() |
128 | { | 137 | { |
138 | |||
129 | lock (m_features) | 139 | lock (m_features) |
130 | { | 140 | { |
131 | m_features["MeshRezEnabled"] = true; | 141 | m_features["MeshRezEnabled"] = true; |
@@ -141,15 +151,21 @@ namespace OpenSim.Region.ClientStack.Linden | |||
141 | 151 | ||
142 | // Extra information for viewers that want to use it | 152 | // Extra information for viewers that want to use it |
143 | // TODO: Take these out of here into their respective modules, like map-server-url | 153 | // TODO: Take these out of here into their respective modules, like map-server-url |
144 | OSDMap extrasMap = new OSDMap(); | 154 | OSDMap extrasMap; |
145 | if (m_SearchURL != string.Empty) | 155 | if(m_features.ContainsKey("OpenSimExtras")) |
156 | { | ||
157 | extrasMap = (OSDMap)m_features["OpenSimExtras"]; | ||
158 | } | ||
159 | else | ||
160 | extrasMap = new OSDMap(); | ||
161 | |||
162 | if (m_SearchURL != string.Empty && m_AllowOverride == true) | ||
146 | extrasMap["search-server-url"] = m_SearchURL; | 163 | extrasMap["search-server-url"] = m_SearchURL; |
147 | if (m_ExportSupported) | 164 | if (m_ExportSupported && m_AllowOverride == true) |
148 | extrasMap["ExportSupported"] = true; | 165 | extrasMap["ExportSupported"] = true; |
149 | 166 | ||
150 | if (extrasMap.Count > 0) | 167 | if (extrasMap.Count > 0) |
151 | m_features["OpenSimExtras"] = extrasMap; | 168 | m_features["OpenSimExtras"] = extrasMap; |
152 | |||
153 | } | 169 | } |
154 | } | 170 | } |
155 | 171 | ||
@@ -204,7 +220,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
204 | OSDMap copy = DeepCopy(); | 220 | OSDMap copy = DeepCopy(); |
205 | 221 | ||
206 | SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest; | 222 | SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest; |
207 | if (handlerOnSimulatorFeaturesRequest != null) | 223 | |
224 | // We will not trigger the event if m_AllowOverride == False | ||
225 | // See Robust.ini/Robust.HG.ini [GridExtraFeatures] - AllowRegionOverride | ||
226 | if (handlerOnSimulatorFeaturesRequest != null && m_AllowOverride == true) | ||
208 | handlerOnSimulatorFeaturesRequest(agentID, ref copy); | 227 | handlerOnSimulatorFeaturesRequest(agentID, ref copy); |
209 | 228 | ||
210 | //Send back data | 229 | //Send back data |
@@ -217,5 +236,42 @@ namespace OpenSim.Region.ClientStack.Linden | |||
217 | 236 | ||
218 | return responsedata; | 237 | return responsedata; |
219 | } | 238 | } |
239 | |||
240 | /// <summary> | ||
241 | /// Gets the grid extra features. | ||
242 | /// </summary> | ||
243 | /// <param name='featuresURI'> | ||
244 | /// The URI Robust uses to handle the get_extra_features request | ||
245 | /// </param> | ||
246 | private void GetGridExtraFeatures(string featuresURI) | ||
247 | { | ||
248 | JsonRpcRequestManager rpc = new JsonRpcRequestManager (); | ||
249 | |||
250 | OSDMap parameters = new OSDMap (); | ||
251 | OSD Params = (OSD)parameters; | ||
252 | if (!rpc.JsonRpcRequest (ref Params, "get_extra_features", featuresURI, UUID.Random ().ToString ())) | ||
253 | { | ||
254 | m_log.Error("[SIMFEATURES]: Could not retrieve extra features from grid. Please check configuration."); | ||
255 | return; | ||
256 | } | ||
257 | parameters = (OSDMap)Params; | ||
258 | OSDMap features = (OSDMap)parameters ["result"]; | ||
259 | |||
260 | if(features.ContainsKey("region_override")) | ||
261 | m_AllowOverride = features ["region_override"].AsBoolean () ; | ||
262 | else | ||
263 | m_AllowOverride = true; | ||
264 | |||
265 | OSDMap test = (OSDMap)features ["extra_features"]; | ||
266 | lock (m_features) | ||
267 | { | ||
268 | OSDMap extrasMap = new OSDMap(); | ||
269 | foreach (string key in test.Keys) | ||
270 | { | ||
271 | extrasMap[key] = test[key]; | ||
272 | } | ||
273 | m_features["OpenSimExtras"] = extrasMap; | ||
274 | } | ||
275 | } | ||
220 | } | 276 | } |
221 | } | 277 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/LocalGridFeaturesServiceInConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/LocalGridFeaturesServiceInConnector.cs new file mode 100644 index 0000000..6cfb099 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/LocalGridFeaturesServiceInConnector.cs | |||
@@ -0,0 +1,129 @@ | |||
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.Reflection; | ||
30 | using System.Collections.Generic; | ||
31 | using log4net; | ||
32 | using Mono.Addins; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Servers; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Server.Base; | ||
39 | using OpenSim.Server.Handlers.Base; | ||
40 | using OpenSim.Server.Handlers.Grid; | ||
41 | using OpenSim.Services.Interfaces; | ||
42 | using OpenSim.Framework.Servers.HttpServer; | ||
43 | |||
44 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid | ||
45 | { | ||
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalGridFeaturesServiceInConnector")] | ||
47 | public class LocalGridExtraFeaturesServiceInConnector : ISharedRegionModule | ||
48 | { | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | private static bool m_Enabled = false; | ||
51 | |||
52 | private IConfigSource m_Config; | ||
53 | bool m_Registered = false; | ||
54 | |||
55 | #region Region Module interface | ||
56 | |||
57 | public void Initialise(IConfigSource config) | ||
58 | { | ||
59 | m_Config = config; | ||
60 | IConfig moduleConfig = config.Configs["Modules"]; | ||
61 | if (moduleConfig != null) | ||
62 | { | ||
63 | string name = moduleConfig.GetString("GridExtraFeaturesServiceInConnector", ""); | ||
64 | if (name == Name) | ||
65 | { | ||
66 | m_log.Info("[GridExtraFeatures]: GridExtraFeatures Service In Connector enabled"); | ||
67 | InitializeService(config); | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | |||
72 | public void InitializeService(IConfigSource config) | ||
73 | { | ||
74 | GridExtraFeaturesHandlers handler = new GridExtraFeaturesHandlers(config); | ||
75 | |||
76 | IHttpServer Server = MainServer.Instance; | ||
77 | |||
78 | Server.AddJsonRPCHandler("get_extra_features", handler.JsonGetGridFeaturesMethod); | ||
79 | |||
80 | } | ||
81 | |||
82 | public void PostInitialise() | ||
83 | { | ||
84 | } | ||
85 | |||
86 | public void Close() | ||
87 | { | ||
88 | } | ||
89 | |||
90 | public Type ReplaceableInterface | ||
91 | { | ||
92 | get { return null; } | ||
93 | } | ||
94 | |||
95 | public string Name | ||
96 | { | ||
97 | get { return "LocalGridExtraFeaturesServiceInConnector"; } | ||
98 | } | ||
99 | |||
100 | public void AddRegion(Scene scene) | ||
101 | { | ||
102 | if (!m_Enabled) | ||
103 | return; | ||
104 | } | ||
105 | |||
106 | public void RemoveRegion(Scene scene) | ||
107 | { | ||
108 | if (!m_Enabled) | ||
109 | return; | ||
110 | } | ||
111 | |||
112 | public void RegionLoaded(Scene scene) | ||
113 | { | ||
114 | if (!m_Enabled) | ||
115 | return; | ||
116 | |||
117 | if (!m_Registered) | ||
118 | { | ||
119 | m_Registered = true; | ||
120 | |||
121 | m_log.Info("[GRID EXTRA FEATURES]: Starting..."); | ||
122 | |||
123 | new GridExtraFeaturesServerInConnector(m_Config, MainServer.Instance, "GridExtraFeaturesService"); | ||
124 | } | ||
125 | } | ||
126 | #endregion | ||
127 | |||
128 | } | ||
129 | } \ No newline at end of file | ||