From 904d6b787a7fc399544145ae023162d6fa43fb63 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 8 Sep 2010 09:53:57 -0700 Subject: First version of the Hypergrid HELO service that will enable different backends to interoperate. --- .../Handlers/Hypergrid/HeloServerConnector.cs | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs new file mode 100644 index 0000000..3b25a52 --- /dev/null +++ b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs @@ -0,0 +1,85 @@ +/* + * 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.IO; +using System.Net; +using System.Reflection; +using Nini.Config; +using log4net; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; + +namespace OpenSim.Server.Handlers.Hypergrid +{ + public class HeloServiceConnector : ServiceConnector + { + private string m_ConfigName = "HeloService"; + + public HeloServiceConnector(IConfigSource config, IHttpServer server, string configName) : + base(config, server, configName) + { + IConfig serverConfig = config.Configs[m_ConfigName]; + if (serverConfig == null) + throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); + + string handlers = serverConfig.GetString("Handlers", "opensim-robust"); + server.AddStreamHandler(new HeloServerGetHandler(handlers)); + } + } + + public class HeloServerGetHandler : BaseStreamHandler + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private string m_HandlersType; + + public HeloServerGetHandler(string handlersType) : + base("GET", "/helo") + { + m_HandlersType = handlersType; + } + + public override byte[] Handle(string path, Stream requestData, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + return OKResponse(httpResponse); + } + + private byte[] OKResponse(OSHttpResponse httpResponse) + { + httpResponse.AddHeader("X-Handlers-Provided", m_HandlersType); + httpResponse.StatusCode = (int)HttpStatusCode.OK; + httpResponse.StatusDescription = "OK"; + return new byte[0]; + } + + } +} -- cgit v1.1 From 3fb4a17f1044f5bd995f703233f656f72ebe5269 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 8 Sep 2010 11:30:38 -0700 Subject: No need for a config var for the HELO message on the server-side. It's robust. --- OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs index 3b25a52..6c83aff 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs @@ -41,17 +41,10 @@ namespace OpenSim.Server.Handlers.Hypergrid { public class HeloServiceConnector : ServiceConnector { - private string m_ConfigName = "HeloService"; - public HeloServiceConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) { - IConfig serverConfig = config.Configs[m_ConfigName]; - if (serverConfig == null) - throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); - - string handlers = serverConfig.GetString("Handlers", "opensim-robust"); - server.AddStreamHandler(new HeloServerGetHandler(handlers)); + server.AddStreamHandler(new HeloServerGetHandler("opensim-robust")); } } -- cgit v1.1 From d301f3fd6ad65e3eb39cfaff65cd3fbb896fa5c1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 8 Sep 2010 14:12:01 -0700 Subject: Renamed the Helo server connector to a consistent name. Added this in connector to both Robust.HG.ini.example and HypergridServiceInConnectorModule. --- OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs index 6c83aff..39baa32 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs @@ -39,9 +39,9 @@ using OpenSim.Server.Handlers.Base; namespace OpenSim.Server.Handlers.Hypergrid { - public class HeloServiceConnector : ServiceConnector + public class HeloServiceInConnector : ServiceConnector { - public HeloServiceConnector(IConfigSource config, IHttpServer server, string configName) : + public HeloServiceInConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) { server.AddStreamHandler(new HeloServerGetHandler("opensim-robust")); @@ -68,6 +68,7 @@ namespace OpenSim.Server.Handlers.Hypergrid private byte[] OKResponse(OSHttpResponse httpResponse) { + m_log.Debug("[HELO]: hi, I was called"); httpResponse.AddHeader("X-Handlers-Provided", m_HandlersType); httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.StatusDescription = "OK"; -- cgit v1.1 From f1f0bc23f4501ba99035283d3407ddad2b21b785 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 12 Sep 2010 13:43:49 -0400 Subject: Formatting cleanup. --- OpenSim/Server/Base/ServerUtils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server') diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index e7a8294..f4472c7 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -62,7 +62,7 @@ namespace OpenSim.Server.Base /// /// /// The arguments which control which constructor is invoked on the plugin - /// + /// public static T LoadPlugin(string dllName, Object[] args) where T:class { string[] parts = dllName.Split(new char[] {':'}); -- cgit v1.1