From 97ebdd4607a3d6aa312adb07292b13ae2b120929 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 19 Sep 2009 16:57:15 +0100 Subject: Adding Xml serialization of Dictionary where object is either another Dictionary or a value that is convertible to a string. --- OpenSim/Server/Base/ServerUtils.cs | 72 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 0a36bbe..ae7ec0f 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -183,5 +183,77 @@ namespace OpenSim.Server.Base return result; } + + public static string BuildQueryString(Dictionary data) + { + string qstring = String.Empty; + + foreach(KeyValuePair kvp in data) + { + string part; + if (kvp.Value != String.Empty) + { + part = System.Web.HttpUtility.UrlEncode(kvp.Key) + + "=" + System.Web.HttpUtility.UrlEncode(kvp.Value); + } + else + { + part = System.Web.HttpUtility.UrlEncode(kvp.Key); + } + + if (qstring != String.Empty) + qstring += "&"; + + qstring += part; + } + + return qstring; + } + + public static string BuildXmlResponse(Dictionary data) + { + XmlDocument doc = new XmlDocument(); + + XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, + "", ""); + + doc.AppendChild(xmlnode); + + XmlElement rootElement = doc.CreateElement("", "ServerResponse", + ""); + + doc.AppendChild(rootElement); + + BuildXmlData(rootElement, data); + + return doc.InnerXml; + } + + private static void BuildXmlData(XmlElement parent, Dictionary data) + { + foreach (KeyValuePair kvp in data) + { + XmlElement elem = parent.OwnerDocument.CreateElement("", + kvp.Key, ""); + + if (kvp.Value is Dictionary) + { + XmlAttribute type = parent.OwnerDocument.CreateAttribute("", + "type", ""); + type.Value = "List"; + + elem.Attributes.Append(type); + + BuildXmlData(elem, (Dictionary)kvp.Value); + } + else + { + elem.AppendChild(parent.OwnerDocument.CreateTextNode( + kvp.Value.ToString())); + } + + parent.AppendChild(elem); + } + } } } -- cgit v1.1 From 2f624800d37bae36cecf1bff191b646d59d86746 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 19 Sep 2009 18:06:25 +0100 Subject: Adding the deserializer for server form/xml replies --- OpenSim/Server/Base/ServerUtils.cs | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index ae7ec0f..6c2b3ed 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -255,5 +255,47 @@ namespace OpenSim.Server.Base parent.AppendChild(elem); } } + + public static Dictionary ParseXmlResponse(string data) + { + Dictionary ret = new Dictionary(); + + XmlDocument doc = new XmlDocument(); + + doc.LoadXml(data); + + XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse"); + + if (rootL.Count != 1) + return ret; + + XmlNode rootNode = rootL[0]; + + ret = ParseElement(rootNode); + + return ret; + } + + private static Dictionary ParseElement(XmlNode element) + { + Dictionary ret = new Dictionary(); + + XmlNodeList partL = element.ChildNodes; + + foreach (XmlNode part in partL) + { + XmlNode type = part.Attributes.GetNamedItem("Type"); + if (type == null || type.Value != "List") + { + ret[part.Name] = part.InnerText; + } + else + { + ret[part.Name] = ParseElement(part); + } + } + + return ret; + } } } -- cgit v1.1 From dd3d52ae1faefbca85e2fe8d8cea67f7db4005ac Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 13:33:58 -0700 Subject: Added test GridClient, which allowed me to remove a few bugs out of the new code. --- OpenSim/Server/Base/ServerUtils.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 6c2b3ed..656fcf5 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -258,6 +258,8 @@ namespace OpenSim.Server.Base public static Dictionary ParseXmlResponse(string data) { + //m_log.DebugFormat("[XXX]: received xml string: {0}", data); + Dictionary ret = new Dictionary(); XmlDocument doc = new XmlDocument(); @@ -284,7 +286,7 @@ namespace OpenSim.Server.Base foreach (XmlNode part in partL) { - XmlNode type = part.Attributes.GetNamedItem("Type"); + XmlNode type = part.Attributes.GetNamedItem("type"); if (type == null || type.Value != "List") { ret[part.Name] = part.InnerText; -- cgit v1.1 From 9bdb585a93f824223f20f248e1411ba6da760624 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Sep 2009 10:56:05 -0700 Subject: Added Protocol versions back, this time in a range model. --- OpenSim/Server/Base/ProtocolVersions.cs | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 OpenSim/Server/Base/ProtocolVersions.cs (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/ProtocolVersions.cs b/OpenSim/Server/Base/ProtocolVersions.cs new file mode 100644 index 0000000..6df27b7 --- /dev/null +++ b/OpenSim/Server/Base/ProtocolVersions.cs @@ -0,0 +1,56 @@ +/* + * 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. + */ + +namespace OpenSim.Server.Base +{ + public class ProtocolVersions + { + /// + /// This is the external protocol versions. It is separate from the OpenSimulator project version. + /// + /// These version numbers should be increased by 1 every time a code + /// change in the Service.Connectors and Server.Handlers, espectively, + /// makes the previous OpenSimulator revision incompatible + /// with the new revision. + /// + /// Changes which are compatible with an older revision (e.g. older revisions experience degraded functionality + /// but not outright failure) do not need a version number increment. + /// + /// Having this version number allows the grid service to reject connections from regions running a version + /// of the code that is too old. + /// + /// + + // The range of acceptable servers for client-side connectors + public readonly static int ClientProtocolVersionMin = 0; + public readonly static int ClientProtocolVersionMax = 0; + + // The range of acceptable clients in server-side handlers + public readonly static int ServerProtocolVersionMin = 0; + public readonly static int ServerProtocolVersionMax = 0; + } +} -- cgit v1.1 From a1aa362866fc59d331780ac799beee4a6d2613c6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Sep 2009 22:48:57 +0100 Subject: Allow the notation config_name@port/dll_name:class_name as a handler spec in OpenSim.Server.ini This allows things like "8003/AssetServirce.dll local@8004/InventoryService.dll" The config name is not yet supported by any modules --- OpenSim/Server/Base/HttpServerBase.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs index 791e1ef..6a1f37c 100644 --- a/OpenSim/Server/Base/HttpServerBase.cs +++ b/OpenSim/Server/Base/HttpServerBase.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using System.Threading; using System.Reflection; using OpenSim.Framework; @@ -45,12 +46,27 @@ namespace OpenSim.Server.Base // The http server instance // protected BaseHttpServer m_HttpServer = null; + protected uint m_Port = 0; + protected Dictionary m_Servers = + new Dictionary(); public IHttpServer HttpServer { get { return m_HttpServer; } } + public IHttpServer GetHttpServer(uint port) + { + if (port == m_Port) + return HttpServer; + + if (m_Servers.ContainsKey(port)) + return m_Servers[port]; + + m_Servers[port] = new BaseHttpServer(port); + return m_Servers[port]; + } + // Handle all the automagical stuff // public HttpServerBase(string prompt, string[] args) : base(prompt, args) @@ -74,6 +90,8 @@ namespace OpenSim.Server.Base Thread.CurrentThread.Abort(); } + m_Port = port; + m_HttpServer = new BaseHttpServer(port); MainServer.Instance = m_HttpServer; -- cgit v1.1 From f00126dc2dfc9e23aa50227f02ee9adbe1efdfa6 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 29 Sep 2009 08:32:59 +0900 Subject: Add copyright header. Formatting cleanup. --- OpenSim/Server/Base/ServerUtils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 656fcf5..db3a4ce 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -188,7 +188,7 @@ namespace OpenSim.Server.Base { string qstring = String.Empty; - foreach(KeyValuePair kvp in data) + foreach (KeyValuePair kvp in data) { string part; if (kvp.Value != String.Empty) -- cgit v1.1 From 1096103d66d7391943efa85553f46a633cf0d3ee Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 29 Sep 2009 09:44:12 +0100 Subject: Fix loading modules with alternate configurations and ports into ROBUST. Make all current modules support the configuration name option --- OpenSim/Server/Base/HttpServerBase.cs | 10 +++++++++- OpenSim/Server/Base/ServerUtils.cs | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/HttpServerBase.cs b/OpenSim/Server/Base/HttpServerBase.cs index 6a1f37c..ed0210f 100644 --- a/OpenSim/Server/Base/HttpServerBase.cs +++ b/OpenSim/Server/Base/HttpServerBase.cs @@ -41,7 +41,7 @@ namespace OpenSim.Server.Base { // Logger // - // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // The http server instance // @@ -55,8 +55,14 @@ namespace OpenSim.Server.Base get { return m_HttpServer; } } + public uint DefaultPort + { + get { return m_Port; } + } + public IHttpServer GetHttpServer(uint port) { + m_Log.InfoFormat("[SERVER]: Requested port {0}", port); if (port == m_Port) return HttpServer; @@ -64,6 +70,8 @@ namespace OpenSim.Server.Base return m_Servers[port]; m_Servers[port] = new BaseHttpServer(port); + m_Servers[port].Start(); + return m_Servers[port]; } diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index db3a4ce..9beadd8 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -141,7 +141,9 @@ namespace OpenSim.Server.Base } catch (Exception e) { - m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException); + if (!(e is System.MissingMethodException)) + m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException); + return null; } return plug; -- cgit v1.1 From ee205e7e812e170f670e690a4e0fa9caa652f226 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 1 Oct 2009 01:00:09 +0900 Subject: Formatting cleanup. --- OpenSim/Server/Base/ProtocolVersions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/ProtocolVersions.cs b/OpenSim/Server/Base/ProtocolVersions.cs index 6df27b7..488a9e6 100644 --- a/OpenSim/Server/Base/ProtocolVersions.cs +++ b/OpenSim/Server/Base/ProtocolVersions.cs @@ -42,7 +42,7 @@ namespace OpenSim.Server.Base /// /// Having this version number allows the grid service to reject connections from regions running a version /// of the code that is too old. - /// + /// /// // The range of acceptable servers for client-side connectors -- cgit v1.1 From 606e831ff5337fb5e94dcebf9d6852bd4c434d4b Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 1 Oct 2009 09:38:36 +0900 Subject: Formatting cleanup. --- OpenSim/Server/Base/ProtocolVersions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Server/Base') diff --git a/OpenSim/Server/Base/ProtocolVersions.cs b/OpenSim/Server/Base/ProtocolVersions.cs index 488a9e6..8db5bb6 100644 --- a/OpenSim/Server/Base/ProtocolVersions.cs +++ b/OpenSim/Server/Base/ProtocolVersions.cs @@ -30,7 +30,7 @@ namespace OpenSim.Server.Base public class ProtocolVersions { /// - /// This is the external protocol versions. It is separate from the OpenSimulator project version. + /// This is the external protocol versions. It is separate from the OpenSimulator project version. /// /// These version numbers should be increased by 1 every time a code /// change in the Service.Connectors and Server.Handlers, espectively, -- cgit v1.1