aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices.AssetServer/Main.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenGridServices.AssetServer/Main.cs')
-rw-r--r--OpenGridServices.AssetServer/Main.cs108
1 files changed, 23 insertions, 85 deletions
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;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Sims; 38using OpenSim.Framework.Sims;
39using OpenSim.Framework.Console; 39using OpenSim.Framework.Console;
40using OpenSim.Framework.Interfaces; 40using OpenSim.Framework.Interfaces;
41using OpenSim.GridInterfaces.Local; // REFACTORING IS NEEDED!!!!!!!!!!!
41using OpenSim.Servers; 42using OpenSim.Servers;
42 43
43namespace OpenGridServices.GridServer 44namespace OpenGridServices.AssetServer
44{ 45{
45 /// <summary> 46 /// <summary>
46 /// </summary> 47 /// </summary>
47 public class OpenGrid_Main : BaseServer, conscmd_callback 48 public class OpenAsset_Main : BaseServer, conscmd_callback
48 { 49 {
49 private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll"; 50 private IObjectContainer db;
50 public GridConfig Cfg;
51 51
52 public static OpenGrid_Main thegrid; 52 public static OpenAsset_Main assetserver;
53 53
54 //public LLUUID highestUUID;
55
56 private SimProfileManager m_simProfileManager;
57
58 private ConsoleBase m_console; 54 private ConsoleBase m_console;
59 55
60 [STAThread] 56 [STAThread]
@@ -62,10 +58,10 @@ namespace OpenGridServices.GridServer
62 { 58 {
63 Console.WriteLine("Starting...\n"); 59 Console.WriteLine("Starting...\n");
64 60
65 thegrid = new OpenGrid_Main(); 61 assetserver = new OpenAsset_Main();
66 thegrid.Startup(); 62 assetserver.Startup();
67 63
68 thegrid.Work(); 64 assetserver.Work();
69 } 65 }
70 66
71 private void Work() 67 private void Work()
@@ -78,57 +74,34 @@ namespace OpenGridServices.GridServer
78 } 74 }
79 } 75 }
80 76
81 private OpenGrid_Main() 77 private OpenAsset_Main()
82 { 78 {
83 m_console = new ConsoleBase("opengrid-gridserver-console.log", "OpenGrid", this, false); 79 m_console = new ConsoleBase("opengrid-AssetServer-console.log", "OpenGrid", this, false);
84 MainConsole.Instance = m_console; 80 MainConsole.Instance = m_console;
85 } 81 }
86 82
87 public void Startup() 83 public void Startup()
88 { 84 {
89 m_console.WriteLine("Main.cs:Startup() - Loading configuration"); 85 /*m_console.WriteLine("Main.cs:Startup() - Loading configuration");
90 Cfg = this.LoadConfigDll(this.ConfigDll); 86 Cfg = this.LoadConfigDll(this.ConfigDll);
91 Cfg.InitConfig(); 87 Cfg.InitConfig(); */
92 88
93 m_console.WriteLine("Main.cs:Startup() - Loading sim profiles from database");
94 m_simProfileManager = new SimProfileManager( this );
95 m_simProfileManager.LoadProfiles();
96 89
97 m_console.WriteLine("Main.cs:Startup() - Starting HTTP process"); 90 m_console.WriteLine("Main.cs:Startup() - Starting HTTP process");
98 BaseHttpServer httpServer = new BaseHttpServer(8001); 91 BaseHttpServer httpServer = new BaseHttpServer(8003);
99
100 httpServer.AddXmlRPCHandler("simulator_login", m_simProfileManager.XmlRpcLoginToSimulatorMethod);
101 92
102 httpServer.AddRestHandler("GET", "/sims/", m_simProfileManager.RestGetSimMethod); 93 /*httpServer.AddRestHandler("GET", "/sims/", m_simProfileManager.RestGetSimMethod);
103 httpServer.AddRestHandler("POST", "/sims/", m_simProfileManager.RestSetSimMethod); 94 httpServer.AddRestHandler("POST", "/sims/", m_simProfileManager.RestSetSimMethod);
104 httpServer.AddRestHandler("GET", "/regions/", m_simProfileManager.RestGetRegionMethod); 95 httpServer.AddRestHandler("GET", "/regions/", m_simProfileManager.RestGetRegionMethod);
105 httpServer.AddRestHandler("POST", "/regions/", m_simProfileManager.RestSetRegionMethod); 96 httpServer.AddRestHandler("POST", "/regions/", m_simProfileManager.RestSetRegionMethod); */
106 97 httpServer.AddRestHAndler("GET", "/assets/", this.assetGetMethod);
107
108 // lbsa71 : This code snippet taken from old http server.
109 // I have no idea what this was supposed to do - looks like an infinite recursion to me.
110 // case "regions":
111 //// DIRTY HACK ALERT
112 //Console.WriteLine("/regions/ accessed");
113 //TheSim = OpenGrid_Main.thegrid._regionmanager.GetProfileByHandle((ulong)Convert.ToUInt64(rest_params[1]));
114 //respstring = ParseREST("/regions/" + rest_params[1], requestBody, HTTPmethod);
115 //break;
116
117 // lbsa71 : I guess these were never used?
118 //Listener.Prefixes.Add("http://+:8001/gods/");
119 //Listener.Prefixes.Add("http://+:8001/highestuuid/");
120 //Listener.Prefixes.Add("http://+:8001/uuidblocks/");
121 98
122 httpServer.Start();
123 99
124 m_console.WriteLine("Main.cs:Startup() - Starting sim status checker"); 100 httpServer.Start();
125 101
126 Timer simCheckTimer = new Timer( 300000 ); // 5 minutes
127 simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
128 simCheckTimer.Enabled = true;
129 } 102 }
130 103
131 private GridConfig LoadConfigDll(string dllName) 104 /*private GridConfig LoadConfigDll(string dllName)
132 { 105 {
133 Assembly pluginAssembly = Assembly.LoadFrom(dllName); 106 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
134 GridConfig config = null; 107 GridConfig config = null;
@@ -154,49 +127,14 @@ namespace OpenGridServices.GridServer
154 } 127 }
155 pluginAssembly = null; 128 pluginAssembly = null;
156 return config; 129 return config;
157 } 130 }*/
158
159 public void CheckSims(object sender, ElapsedEventArgs e)
160 {
161 foreach (SimProfileBase sim in m_simProfileManager.SimProfiles.Values)
162 {
163 string SimResponse = "";
164 try
165 {
166 WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus/");
167 CheckSim.Method = "GET";
168 CheckSim.ContentType = "text/plaintext";
169 CheckSim.ContentLength = 0;
170
171 StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII);
172 stOut.Write("");
173 stOut.Close();
174
175 StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream());
176 SimResponse = stIn.ReadToEnd();
177 stIn.Close();
178 }
179 catch
180 {
181 }
182
183 if (SimResponse == "OK")
184 {
185 m_simProfileManager.SimProfiles[sim.UUID].online = true;
186 }
187 else
188 {
189 m_simProfileManager.SimProfiles[sim.UUID].online = false;
190 }
191 }
192 }
193 131
194 public void RunCmd(string cmd, string[] cmdparams) 132 public void RunCmd(string cmd, string[] cmdparams)
195 { 133 {
196 switch (cmd) 134 switch (cmd)
197 { 135 {
198 case "help": 136 case "help":
199 m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)"); 137 m_console.WriteLine("shutdown - shutdown this asset server (USE CAUTION!)");
200 break; 138 break;
201 139
202 case "shutdown": 140 case "shutdown":