From 002336e95c928405394c18eb7d7e77e7b15bd259 Mon Sep 17 00:00:00 2001 From: gareth Date: Mon, 30 Apr 2007 02:48:05 +0000 Subject: Done some more conversion work on the asset server --- OpenGridServices.AssetServer/Main.cs | 108 ++++++++--------------------------- 1 file changed, 23 insertions(+), 85 deletions(-) (limited to 'OpenGridServices.AssetServer/Main.cs') diff --git a/OpenGridServices.AssetServer/Main.cs b/OpenGridServices.AssetServer/Main.cs index 69cba9c..473c483 100644 --- a/OpenGridServices.AssetServer/Main.cs +++ b/OpenGridServices.AssetServer/Main.cs @@ -37,24 +37,20 @@ using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Sims; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Interfaces; +using OpenSim.GridInterfaces.Local; // REFACTORING IS NEEDED!!!!!!!!!!! using OpenSim.Servers; -namespace OpenGridServices.GridServer +namespace OpenGridServices.AssetServer { /// /// - public class OpenGrid_Main : BaseServer, conscmd_callback + public class OpenAsset_Main : BaseServer, conscmd_callback { - private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll"; - public GridConfig Cfg; + private IObjectContainer db; - public static OpenGrid_Main thegrid; - - //public LLUUID highestUUID; - - private SimProfileManager m_simProfileManager; - + public static OpenAsset_Main assetserver; + private ConsoleBase m_console; [STAThread] @@ -62,10 +58,10 @@ namespace OpenGridServices.GridServer { Console.WriteLine("Starting...\n"); - thegrid = new OpenGrid_Main(); - thegrid.Startup(); + assetserver = new OpenAsset_Main(); + assetserver.Startup(); - thegrid.Work(); + assetserver.Work(); } private void Work() @@ -78,57 +74,34 @@ namespace OpenGridServices.GridServer } } - private OpenGrid_Main() + private OpenAsset_Main() { - m_console = new ConsoleBase("opengrid-gridserver-console.log", "OpenGrid", this, false); + m_console = new ConsoleBase("opengrid-AssetServer-console.log", "OpenGrid", this, false); MainConsole.Instance = m_console; } public void Startup() { - m_console.WriteLine("Main.cs:Startup() - Loading configuration"); + /*m_console.WriteLine("Main.cs:Startup() - Loading configuration"); Cfg = this.LoadConfigDll(this.ConfigDll); - Cfg.InitConfig(); - - m_console.WriteLine("Main.cs:Startup() - Loading sim profiles from database"); - m_simProfileManager = new SimProfileManager( this ); - m_simProfileManager.LoadProfiles(); + Cfg.InitConfig(); */ + m_console.WriteLine("Main.cs:Startup() - Starting HTTP process"); - BaseHttpServer httpServer = new BaseHttpServer(8001); - - httpServer.AddXmlRPCHandler("simulator_login", m_simProfileManager.XmlRpcLoginToSimulatorMethod); + BaseHttpServer httpServer = new BaseHttpServer(8003); - httpServer.AddRestHandler("GET", "/sims/", m_simProfileManager.RestGetSimMethod); + /*httpServer.AddRestHandler("GET", "/sims/", m_simProfileManager.RestGetSimMethod); httpServer.AddRestHandler("POST", "/sims/", m_simProfileManager.RestSetSimMethod); httpServer.AddRestHandler("GET", "/regions/", m_simProfileManager.RestGetRegionMethod); - httpServer.AddRestHandler("POST", "/regions/", m_simProfileManager.RestSetRegionMethod); - - - // lbsa71 : This code snippet taken from old http server. - // I have no idea what this was supposed to do - looks like an infinite recursion to me. - // case "regions": - //// DIRTY HACK ALERT - //Console.WriteLine("/regions/ accessed"); - //TheSim = OpenGrid_Main.thegrid._regionmanager.GetProfileByHandle((ulong)Convert.ToUInt64(rest_params[1])); - //respstring = ParseREST("/regions/" + rest_params[1], requestBody, HTTPmethod); - //break; - - // lbsa71 : I guess these were never used? - //Listener.Prefixes.Add("http://+:8001/gods/"); - //Listener.Prefixes.Add("http://+:8001/highestuuid/"); - //Listener.Prefixes.Add("http://+:8001/uuidblocks/"); + httpServer.AddRestHandler("POST", "/regions/", m_simProfileManager.RestSetRegionMethod); */ + httpServer.AddRestHAndler("GET", "/assets/", this.assetGetMethod); - httpServer.Start(); - m_console.WriteLine("Main.cs:Startup() - Starting sim status checker"); + httpServer.Start(); - Timer simCheckTimer = new Timer( 300000 ); // 5 minutes - simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims); - simCheckTimer.Enabled = true; } - private GridConfig LoadConfigDll(string dllName) + /*private GridConfig LoadConfigDll(string dllName) { Assembly pluginAssembly = Assembly.LoadFrom(dllName); GridConfig config = null; @@ -154,49 +127,14 @@ namespace OpenGridServices.GridServer } pluginAssembly = null; return config; - } - - public void CheckSims(object sender, ElapsedEventArgs e) - { - foreach (SimProfileBase sim in m_simProfileManager.SimProfiles.Values) - { - string SimResponse = ""; - try - { - WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus/"); - CheckSim.Method = "GET"; - CheckSim.ContentType = "text/plaintext"; - CheckSim.ContentLength = 0; - - StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII); - stOut.Write(""); - stOut.Close(); - - StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream()); - SimResponse = stIn.ReadToEnd(); - stIn.Close(); - } - catch - { - } - - if (SimResponse == "OK") - { - m_simProfileManager.SimProfiles[sim.UUID].online = true; - } - else - { - m_simProfileManager.SimProfiles[sim.UUID].online = false; - } - } - } + }*/ public void RunCmd(string cmd, string[] cmdparams) { switch (cmd) { case "help": - m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)"); + m_console.WriteLine("shutdown - shutdown this asset server (USE CAUTION!)"); break; case "shutdown": -- cgit v1.1