Simulator Extra Features Service

Provide a means for regions to fetch extra features supported by modern viewers from a central location
.
bullet-2.82
BlueWall 2014-07-30 11:19:34 -04:00
parent a4107cb6c7
commit e0d8f42e6b
7 changed files with 415 additions and 9 deletions

View File

@ -56,13 +56,15 @@ namespace OpenSim.Region.ClientStack.Linden
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimulatorFeaturesModule")]
public class SimulatorFeaturesModule : ISharedRegionModule, ISimulatorFeaturesModule
{
// private static readonly ILog m_log =
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest;
private Scene m_scene;
bool m_AllowOverride = true;
/// <summary>
/// Simulator features
/// </summary>
@ -75,8 +77,15 @@ namespace OpenSim.Region.ClientStack.Linden
public void Initialise(IConfigSource source)
{
IConfig config = source.Configs["SimulatorFeatures"];
if (config != null)
IConfig config = source.Configs ["SimulatorFeatures"];
string featuresURI = config.GetString ("ExtraFeaturesServiceURI", string.Empty);
if (string.IsNullOrEmpty (featuresURI)) {
m_log.Info ("ExtraFeaturesServiceURI is undefined. The grid's ExtraFeatures will not be available to regions in this instnace.");
} else {
GetGridExtraFeatures(featuresURI);
}
if (config != null && m_AllowOverride == true)
{
m_SearchURL = config.GetString("SearchServerURI", string.Empty);
@ -126,6 +135,7 @@ namespace OpenSim.Region.ClientStack.Linden
/// </remarks>
private void AddDefaultFeatures()
{
lock (m_features)
{
m_features["MeshRezEnabled"] = true;
@ -141,15 +151,21 @@ namespace OpenSim.Region.ClientStack.Linden
// Extra information for viewers that want to use it
// TODO: Take these out of here into their respective modules, like map-server-url
OSDMap extrasMap = new OSDMap();
if (m_SearchURL != string.Empty)
OSDMap extrasMap;
if(m_features.ContainsKey("OpenSimExtras"))
{
extrasMap = (OSDMap)m_features["OpenSimExtras"];
}
else
extrasMap = new OSDMap();
if (m_SearchURL != string.Empty && m_AllowOverride == true)
extrasMap["search-server-url"] = m_SearchURL;
if (m_ExportSupported)
if (m_ExportSupported && m_AllowOverride == true)
extrasMap["ExportSupported"] = true;
if (extrasMap.Count > 0)
m_features["OpenSimExtras"] = extrasMap;
}
}
@ -204,7 +220,10 @@ namespace OpenSim.Region.ClientStack.Linden
OSDMap copy = DeepCopy();
SimulatorFeaturesRequestDelegate handlerOnSimulatorFeaturesRequest = OnSimulatorFeaturesRequest;
if (handlerOnSimulatorFeaturesRequest != null)
// We will not trigger the event if m_AllowOverride == False
// See Robust.ini/Robust.HG.ini [GridExtraFeatures] - AllowRegionOverride
if (handlerOnSimulatorFeaturesRequest != null && m_AllowOverride == true)
handlerOnSimulatorFeaturesRequest(agentID, ref copy);
//Send back data
@ -217,5 +236,42 @@ namespace OpenSim.Region.ClientStack.Linden
return responsedata;
}
/// <summary>
/// Gets the grid extra features.
/// </summary>
/// <param name='featuresURI'>
/// The URI Robust uses to handle the get_extra_features request
/// </param>
private void GetGridExtraFeatures(string featuresURI)
{
JsonRpcRequestManager rpc = new JsonRpcRequestManager ();
OSDMap parameters = new OSDMap ();
OSD Params = (OSD)parameters;
if (!rpc.JsonRpcRequest (ref Params, "get_extra_features", featuresURI, UUID.Random ().ToString ()))
{
m_log.Error("[SIMFEATURES]: Could not retrieve extra features from grid. Please check configuration.");
return;
}
parameters = (OSDMap)Params;
OSDMap features = (OSDMap)parameters ["result"];
if(features.ContainsKey("region_override"))
m_AllowOverride = features ["region_override"].AsBoolean () ;
else
m_AllowOverride = true;
OSDMap test = (OSDMap)features ["extra_features"];
lock (m_features)
{
OSDMap extrasMap = new OSDMap();
foreach (string key in test.Keys)
{
extrasMap[key] = test[key];
}
m_features["OpenSimExtras"] = extrasMap;
}
}
}
}

View File

@ -0,0 +1,129 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Reflection;
using System.Collections.Generic;
using log4net;
using Mono.Addins;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base;
using OpenSim.Server.Handlers.Grid;
using OpenSim.Services.Interfaces;
using OpenSim.Framework.Servers.HttpServer;
namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalGridFeaturesServiceInConnector")]
public class LocalGridExtraFeaturesServiceInConnector : ISharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static bool m_Enabled = false;
private IConfigSource m_Config;
bool m_Registered = false;
#region Region Module interface
public void Initialise(IConfigSource config)
{
m_Config = config;
IConfig moduleConfig = config.Configs["Modules"];
if (moduleConfig != null)
{
string name = moduleConfig.GetString("GridExtraFeaturesServiceInConnector", "");
if (name == Name)
{
m_log.Info("[GridExtraFeatures]: GridExtraFeatures Service In Connector enabled");
InitializeService(config);
}
}
}
public void InitializeService(IConfigSource config)
{
GridExtraFeaturesHandlers handler = new GridExtraFeaturesHandlers(config);
IHttpServer Server = MainServer.Instance;
Server.AddJsonRPCHandler("get_extra_features", handler.JsonGetGridFeaturesMethod);
}
public void PostInitialise()
{
}
public void Close()
{
}
public Type ReplaceableInterface
{
get { return null; }
}
public string Name
{
get { return "LocalGridExtraFeaturesServiceInConnector"; }
}
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
}
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
return;
}
public void RegionLoaded(Scene scene)
{
if (!m_Enabled)
return;
if (!m_Registered)
{
m_Registered = true;
m_log.Info("[GRID EXTRA FEATURES]: Starting...");
new GridExtraFeaturesServerInConnector(m_Config, MainServer.Instance, "GridExtraFeaturesService");
}
}
#endregion
}
}

View File

@ -0,0 +1,118 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.IO;
using System.Net;
using System.Reflection;
using System.Security;
using System.Text;
using log4net;
using Nini.Config;
using Nwc.XmlRpc;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenMetaverse.StructuredData;
namespace OpenSim.Server.Handlers.Grid
{
/// <summary>
/// Grid extra features handlers.
/// <para>Allows grid level configuration of OpenSimExtra items.</para>
/// <para>Option to control region override of these settings.</para>
/// </summary>
public class GridExtraFeaturesHandlers
{
private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Hashtable m_ExtraFeatures = new Hashtable();
private bool m_AllowRegionOverride = true;
public GridExtraFeaturesHandlers(IConfigSource configSource)
{
try
{
IConfig featuresCfg = configSource.Configs["GridExtraFeatures"];
foreach( string key in featuresCfg.GetKeys())
{
if(key != "AllowRegionOverride")
{
string value = featuresCfg.GetString(key);
// map the value to the viewer supported extra features
// add additional ones here as support is added in the viewer
// and place the configuration option in [GridExtraFeatures].
switch(key)
{
case "SearchServerURI":
m_ExtraFeatures["search-server-url"] = value;
break;
case "MapImageServerURI":
m_ExtraFeatures["map-server-url"] = value;
break;
case "DestinationGuideURI":
m_ExtraFeatures["destination-guide-url"] = value;
break;
case "ExportSupported":
m_ExtraFeatures["ExportSupported"] = value;
break;
default:
m_Log.InfoFormat("{0} not yet supported.");
break;
}
}
else
m_AllowRegionOverride = featuresCfg.GetBoolean(key);
}
}
catch (Exception)
{
m_Log.Warn("[GRID EXTRA FEATURES SERVICE]: Cannot get grid features from config source, allowing region override");
}
}
public bool JsonGetGridFeaturesMethod(OSDMap json, ref JsonRpcResponse response)
{
OSDMap features = new OSDMap();
OSDMap json_map = new OSDMap();
foreach (string key in m_ExtraFeatures.Keys)
{
features[key] = OSD.FromString(m_ExtraFeatures[key].ToString());
}
json_map["extra_features"] = features;
json_map["region_override"] = m_AllowRegionOverride.ToString();
response.Result = json_map;
return true;
}
}
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;
using OpenMetaverse;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Server.Handlers.Base;
namespace OpenSim.Server.Handlers.Grid
{
public class GridExtraFeaturesServerInConnector : ServiceConnector
{
public GridExtraFeaturesServerInConnector(IConfigSource config, IHttpServer server, string configName) :
base(config, server, configName)
{
GridExtraFeaturesHandlers handler = new GridExtraFeaturesHandlers(config);
server.AddJsonRPCHandler("get_extra_features", handler.JsonGetGridFeaturesMethod);
}
}
}

View File

@ -538,6 +538,11 @@
[SimulatorFeatures]
;# {ExtraFeaturesServiceURI} {} {URL to the grid ExtraFeatures Service} {}
;; The grid can supply global values for extra simulator features to be
;; passed to supporting viewers. The grid may choose to disallow local
;; settings.
; ExtraFeaturesServiceURI = "http://127.0.0.1:9000/"
;# {MapImageServerURI} {} {URL for the map server} {}
; Experimental new information sent in SimulatorFeatures cap for Kokua
; viewers

View File

@ -45,6 +45,7 @@ InventoryInConnector = "8003/OpenSim.Server.Handlers.dll:XInventoryInConnector"
;VoiceConnector = "8004/OpenSim.Server.Handlers.dll:FreeswitchServerConnector"
GridServiceConnector = "8003/OpenSim.Server.Handlers.dll:GridServiceConnector"
GridInfoServerInConnector = "8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector"
GridExtraFeaturesServerInConnector = "8002/OpenSim.Server.Handlers.dll:GridExtraFeaturesServerInConnector"
AuthenticationServiceConnector = "8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector"
OpenIdServerConnector = "8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector"
AvatarServiceConnector = "8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector"
@ -484,6 +485,29 @@ HGAssetServiceConnector = "HGAssetService@8002/OpenSim.Server.Handlers.dll:Asset
; this is the entry point for all user-related HG services
; uas = http://127.0.0.1:8002/
[GridExtraFeatures]
; These are propagated out to the regions as default settings for the
; SimulatorFeatures to be sent to user's viewer when they teleport via
; Hypergrid into this grid.
;
; Allow regions to override our defaults.
;AllowRegionOverride = true
; Search Server URI
;SearchServerURI = "http://example.com:8200/"
; Map Server URI
;MapImageServerURI = "http://example.com:8200/"
; Grid Destination Guide URI
;DestinationGuideURI = "http://example.com:8200/"
; Grid Allow Export
;ExportSupported = true
[GatekeeperService]
LocalServiceModule = "OpenSim.Services.HypergridService.dll:GatekeeperService"
;; for the service

View File

@ -36,6 +36,7 @@ InventoryInConnector = "8003/OpenSim.Server.Handlers.dll:XInventoryInConnector"
;VoiceConnector = "8004/OpenSim.Server.Handlers.dll:FreeswitchServerConnector"
GridServiceConnector = "8003/OpenSim.Server.Handlers.dll:GridServiceConnector"
GridInfoServerInConnector = "8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector"
GridExtraFeaturesServerInConnector = "8002/OpenSim.Server.Handlers.dll:GridExtraFeaturesServerInConnector"
AuthenticationServiceConnector = "8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector"
OpenIdServerConnector = "8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector"
AvatarServiceConnector = "8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector"
@ -456,6 +457,29 @@ MapGetServiceConnector = "8002/OpenSim.Server.Handlers.dll:MapGetServiceConnecto
; password help: optional: page providing password assistance for users of your grid
;password = http://127.0.0.1/password
[GridExtraFeatures]
; These are propagated out to the regions as default settings for the
; SimulatorFeatures to be sent to user's viewer when they teleport via
; Hypergrid into this grid.
;
; Allow regions to override our defaults.
;AllowRegionOverride = true
; Search Server URI
;SearchServerURI = "http://example.com:8200/"
; Map Server URI
;MapImageServerURI = "http://example.com:8200/"
; Grid Destination Guide URI
;DestinationGuideURI = "http://example.com:8200/"
; Grid Allow Export
;ExportSupported = true
[UserProfilesService]
LocalServiceModule = "OpenSim.Services.UserProfilesService.dll:UserProfilesService"
Enabled = false