diff options
author | MW | 2007-05-16 12:44:58 +0000 |
---|---|---|
committer | MW | 2007-05-16 12:44:58 +0000 |
commit | 3d93d390485075345442b9b5ea35eed88a9cab49 (patch) | |
tree | a51cdb72cd310ae3f579650886836ddc0211d986 /OpenSim.RegionServer/OpenSimMain.cs | |
parent | made QueItem a nested class in SimClient. (diff) | |
download | opensim-SC-3d93d390485075345442b9b5ea35eed88a9cab49.zip opensim-SC-3d93d390485075345442b9b5ea35eed88a9cab49.tar.gz opensim-SC-3d93d390485075345442b9b5ea35eed88a9cab49.tar.bz2 opensim-SC-3d93d390485075345442b9b5ea35eed88a9cab49.tar.xz |
started to refactor startup code and to move udp server code out to its own class (currently not being used though) so that a single instance can handle multiple regions (each will need to be listening on a separate udp port)
Diffstat (limited to '')
-rw-r--r-- | OpenSim.RegionServer/OpenSimMain.cs | 340 |
1 files changed, 164 insertions, 176 deletions
diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs index fc604b7..9995d96 100644 --- a/OpenSim.RegionServer/OpenSimMain.cs +++ b/OpenSim.RegionServer/OpenSimMain.cs | |||
@@ -56,7 +56,6 @@ namespace OpenSim | |||
56 | 56 | ||
57 | public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback | 57 | public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback |
58 | { | 58 | { |
59 | //private SimConfig Cfg; | ||
60 | private IGenericConfig localConfig; | 59 | private IGenericConfig localConfig; |
61 | //private IGenericConfig remoteConfig; | 60 | //private IGenericConfig remoteConfig; |
62 | private PhysicsManager physManager; | 61 | private PhysicsManager physManager; |
@@ -65,7 +64,6 @@ namespace OpenSim | |||
65 | private World LocalWorld; | 64 | private World LocalWorld; |
66 | private AssetCache AssetCache; | 65 | private AssetCache AssetCache; |
67 | private InventoryCache InventoryCache; | 66 | private InventoryCache InventoryCache; |
68 | //private Dictionary<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>(); | ||
69 | private Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); | 67 | private Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); |
70 | private DateTime startuptime; | 68 | private DateTime startuptime; |
71 | private RegionInfo regionData; | 69 | private RegionInfo regionData; |
@@ -79,16 +77,16 @@ namespace OpenSim | |||
79 | private AsyncCallback ReceivedData; | 77 | private AsyncCallback ReceivedData; |
80 | 78 | ||
81 | private System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer(); | 79 | private System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer(); |
82 | //private string ConfigDll = "OpenSim.Config.SimConfigDb4o.dll"; | ||
83 | public string m_physicsEngine; | 80 | public string m_physicsEngine; |
84 | public bool m_sandbox = false; | 81 | public bool m_sandbox = false; |
85 | public bool m_loginserver; | 82 | public bool m_loginserver; |
86 | public OpenGridProtocolServer OGSServer; | ||
87 | public bool user_accounts = false; | 83 | public bool user_accounts = false; |
88 | public bool gridLocalAsset = false; | 84 | public bool gridLocalAsset = false; |
89 | private bool configFileSetup = false; | 85 | private bool configFileSetup = false; |
90 | public string m_config; | 86 | public string m_config; |
91 | 87 | ||
88 | protected BaseHttpServer httpServer; | ||
89 | |||
92 | protected ConsoleBase m_console; | 90 | protected ConsoleBase m_console; |
93 | 91 | ||
94 | public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool verbose, string configFile) | 92 | public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool verbose, string configFile) |
@@ -122,42 +120,18 @@ namespace OpenSim | |||
122 | { | 120 | { |
123 | this.SetupFromConfigFile(this.localConfig); | 121 | this.SetupFromConfigFile(this.localConfig); |
124 | } | 122 | } |
125 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Loading configuration"); | 123 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Loading configuration"); |
126 | this.regionData.InitConfig(this.m_sandbox, this.localConfig); | 124 | this.regionData.InitConfig(this.m_sandbox, this.localConfig); |
127 | this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change | 125 | this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change |
128 | 126 | ||
129 | |||
130 | GridServers = new Grid(); | 127 | GridServers = new Grid(); |
131 | if (m_sandbox) | 128 | if (m_sandbox) |
132 | { | 129 | { |
133 | GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; | 130 | this.SetupLocalGridServers(); |
134 | GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll"; | ||
135 | |||
136 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Starting in Sandbox mode"); | ||
137 | } | 131 | } |
138 | else | 132 | else |
139 | { | 133 | { |
140 | if (this.gridLocalAsset) | 134 | this.SetupRemoteGridServers(); |
141 | { | ||
142 | GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; | ||
143 | } | ||
144 | else | ||
145 | { | ||
146 | GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll"; | ||
147 | } | ||
148 | GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll"; | ||
149 | |||
150 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Starting in Grid mode"); | ||
151 | } | ||
152 | |||
153 | try | ||
154 | { | ||
155 | GridServers.Initialise(); | ||
156 | } | ||
157 | catch (Exception e) | ||
158 | { | ||
159 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,e.Message + "\nSorry, could not setup the grid interface"); | ||
160 | Environment.Exit(1); | ||
161 | } | 135 | } |
162 | 136 | ||
163 | startuptime = DateTime.Now; | 137 | startuptime = DateTime.Now; |
@@ -169,63 +143,120 @@ namespace OpenSim | |||
169 | } | 143 | } |
170 | catch (Exception e) | 144 | catch (Exception e) |
171 | { | 145 | { |
172 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,e.Message + "\nSorry, could not setup local cache"); | 146 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup local cache"); |
173 | Environment.Exit(1); | 147 | Environment.Exit(1); |
174 | } | 148 | } |
175 | 149 | ||
176 | PacketServer packetServer = new PacketServer(this); | 150 | PacketServer packetServer = new PacketServer(this); |
177 | 151 | ||
178 | |||
179 | //should be passing a IGenericConfig object to these so they can read the config data they want from it | 152 | //should be passing a IGenericConfig object to these so they can read the config data they want from it |
180 | GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey); | 153 | GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey); |
181 | IGridServer gridServer = GridServers.GridServer; | 154 | IGridServer gridServer = GridServers.GridServer; |
182 | gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey); | 155 | gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey); |
183 | 156 | ||
184 | if (!m_sandbox) | 157 | if (!m_sandbox) |
185 | { | 158 | { |
186 | if (GridServers.GridServer.RequestConnection(regionData.SimUUID, regionData.IPListenAddr, (uint)regionData.IPListenPort)) | 159 | this.ConnectToRemoteGridServer(); |
160 | } | ||
161 | |||
162 | this.SetupLocalWorld(); | ||
163 | |||
164 | if (m_sandbox) | ||
165 | { | ||
166 | AssetCache.LoadDefaultTextureSet(); | ||
167 | } | ||
168 | |||
169 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Initialising HTTP server"); | ||
170 | |||
171 | this.SetupHttpListener(); | ||
172 | |||
173 | LoginServer loginServer = null; | ||
174 | LoginServer adminLoginServer = null; | ||
175 | |||
176 | bool sandBoxWithLoginServer = m_loginserver && m_sandbox; | ||
177 | if (sandBoxWithLoginServer) | ||
178 | { | ||
179 | loginServer = new LoginServer(gridServer, regionData.IPListenAddr, regionData.IPListenPort, regionData.RegionLocX, regionData.RegionLocY, this.user_accounts); | ||
180 | loginServer.Startup(); | ||
181 | |||
182 | if (user_accounts) | ||
187 | { | 183 | { |
188 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Success: Got a grid connection OK!"); | 184 | //sandbox mode with loginserver using accounts |
185 | this.GridServers.UserServer = loginServer; | ||
186 | adminLoginServer = loginServer; | ||
187 | |||
188 | httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod); | ||
189 | } | 189 | } |
190 | else | 190 | else |
191 | { | 191 | { |
192 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL,"Main.cs:Startup() - FAILED: Unable to get connection to grid. Shutting down."); | 192 | //sandbox mode with loginserver not using accounts |
193 | Shutdown(); | 193 | httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod); |
194 | } | 194 | } |
195 | } | ||
195 | 196 | ||
196 | GridServers.AssetServer.SetServerInfo((string)((RemoteGridBase)GridServers.GridServer).GridData["asset_url"], (string)((RemoteGridBase)GridServers.GridServer).GridData["asset_sendkey"]); | 197 | AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer); |
198 | adminWebFront.LoadMethods(httpServer); | ||
197 | 199 | ||
198 | // If we are being told to load a file, load it. | 200 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting HTTP server"); |
199 | string dataUri = (string)((RemoteGridBase)GridServers.GridServer).GridData["data_uri"]; | 201 | httpServer.Start(); |
200 | |||
201 | if ( !String.IsNullOrEmpty( dataUri ) ) | ||
202 | { | ||
203 | this.LocalWorld.m_datastore = dataUri; | ||
204 | } | ||
205 | 202 | ||
206 | if (((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString() != "") | 203 | MainServerListener(); |
207 | { | ||
208 | // The grid server has told us who we are | ||
209 | // We must obey the grid server. | ||
210 | try | ||
211 | { | ||
212 | regionData.RegionLocX = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locx"].ToString()); | ||
213 | regionData.RegionLocY = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locy"].ToString()); | ||
214 | regionData.RegionName = ((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString(); | ||
215 | } | ||
216 | catch (Exception e) | ||
217 | { | ||
218 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL,e.Message + "\nBAD ERROR! THIS SHOULD NOT HAPPEN! Bad GridData from the grid interface!!!! ZOMG!!!"); | ||
219 | Environment.Exit(1); | ||
220 | } | ||
221 | } | ||
222 | 204 | ||
205 | m_heartbeatTimer.Enabled = true; | ||
206 | m_heartbeatTimer.Interval = 100; | ||
207 | m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat); | ||
208 | } | ||
209 | |||
210 | # region Setup methods | ||
211 | protected virtual void SetupLocalGridServers() | ||
212 | { | ||
213 | GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; | ||
214 | GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll"; | ||
215 | |||
216 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Sandbox mode"); | ||
217 | |||
218 | try | ||
219 | { | ||
220 | GridServers.Initialise(); | ||
221 | } | ||
222 | catch (Exception e) | ||
223 | { | ||
224 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface"); | ||
225 | Environment.Exit(1); | ||
226 | } | ||
227 | } | ||
228 | |||
229 | protected virtual void SetupRemoteGridServers() | ||
230 | { | ||
231 | if (this.gridLocalAsset) | ||
232 | { | ||
233 | GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; | ||
234 | } | ||
235 | else | ||
236 | { | ||
237 | GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll"; | ||
223 | } | 238 | } |
239 | GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll"; | ||
224 | 240 | ||
241 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Grid mode"); | ||
225 | 242 | ||
226 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL,"Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString()); | 243 | try |
227 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Initialising world"); | 244 | { |
245 | GridServers.Initialise(); | ||
246 | } | ||
247 | catch (Exception e) | ||
248 | { | ||
249 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface"); | ||
250 | Environment.Exit(1); | ||
251 | } | ||
252 | } | ||
253 | |||
254 | protected virtual void SetupLocalWorld() | ||
255 | { | ||
256 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString()); | ||
257 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Initialising world"); | ||
228 | m_console.componentname = "Region " + regionData.RegionName; | 258 | m_console.componentname = "Region " + regionData.RegionName; |
259 | |||
229 | LocalWorld = new World(this._packetServer.ClientThreads, regionData, regionData.RegionHandle, regionData.RegionName); | 260 | LocalWorld = new World(this._packetServer.ClientThreads, regionData, regionData.RegionHandle, regionData.RegionName); |
230 | LocalWorld.InventoryCache = InventoryCache; | 261 | LocalWorld.InventoryCache = InventoryCache; |
231 | LocalWorld.AssetCache = AssetCache; | 262 | LocalWorld.AssetCache = AssetCache; |
@@ -241,28 +272,18 @@ namespace OpenSim | |||
241 | LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. | 272 | LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. |
242 | LocalWorld.LoadWorldMap(); | 273 | LocalWorld.LoadWorldMap(); |
243 | 274 | ||
244 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting up messaging system"); | 275 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting up messaging system"); |
245 | LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); //should be reading from the config file what physics engine to use | 276 | LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); //should be reading from the config file what physics engine to use |
246 | LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D()); | 277 | LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D()); |
247 | |||
248 | |||
249 | LocalWorld.LoadPrimsFromStorage(); | 278 | LocalWorld.LoadPrimsFromStorage(); |
279 | } | ||
250 | 280 | ||
251 | if (m_sandbox) | 281 | protected virtual void SetupHttpListener() |
252 | { | 282 | { |
253 | AssetCache.LoadDefaultTextureSet(); | 283 | httpServer = new BaseHttpServer(regionData.IPListenPort); |
254 | } | ||
255 | |||
256 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Initialising HTTP server"); | ||
257 | // HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort); | ||
258 | |||
259 | BaseHttpServer httpServer = new BaseHttpServer(regionData.IPListenPort); | ||
260 | 284 | ||
261 | if (gridServer.GetName() == "Remote") | 285 | if (this.GridServers.GridServer.GetName() == "Remote") |
262 | { | 286 | { |
263 | // should startup the OGS protocol server here | ||
264 | // Are we actually using this? | ||
265 | OGSServer = new OpenGridProtocolServer(this.regionData.IPListenPort - 500); // Changed so we can have more than one OGSServer per machine. | ||
266 | 287 | ||
267 | // we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server | 288 | // we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server |
268 | httpServer.AddXmlRPCHandler("expect_user", | 289 | httpServer.AddXmlRPCHandler("expect_user", |
@@ -286,13 +307,13 @@ namespace OpenSim | |||
286 | agent_data.child = false; | 307 | agent_data.child = false; |
287 | } | 308 | } |
288 | 309 | ||
289 | if (((RemoteGridBase)gridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode)) | 310 | if (((RemoteGridBase)this.GridServers.GridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode)) |
290 | { | 311 | { |
291 | ((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode] = agent_data; | 312 | ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode] = agent_data; |
292 | } | 313 | } |
293 | else | 314 | else |
294 | { | 315 | { |
295 | ((RemoteGridBase)gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data); | 316 | ((RemoteGridBase)this.GridServers.GridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data); |
296 | } | 317 | } |
297 | 318 | ||
298 | return new XmlRpcResponse(); | 319 | return new XmlRpcResponse(); |
@@ -308,11 +329,11 @@ namespace OpenSim | |||
308 | agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); | 329 | agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); |
309 | agent_data.startpos = new LLVector3(Single.Parse((string)requestData["pos_x"]), Single.Parse((string)requestData["pos_y"]), Single.Parse((string)requestData["pos_z"])); | 330 | agent_data.startpos = new LLVector3(Single.Parse((string)requestData["pos_x"]), Single.Parse((string)requestData["pos_y"]), Single.Parse((string)requestData["pos_z"])); |
310 | 331 | ||
311 | if (((RemoteGridBase)gridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode)) | 332 | if (((RemoteGridBase)this.GridServers.GridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode)) |
312 | { | 333 | { |
313 | ((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode].firstname = agent_data.firstname; | 334 | ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].firstname = agent_data.firstname; |
314 | ((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode].lastname = agent_data.lastname; | 335 | ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].lastname = agent_data.lastname; |
315 | ((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode].startpos = agent_data.startpos; | 336 | ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].startpos = agent_data.startpos; |
316 | } | 337 | } |
317 | 338 | ||
318 | return new XmlRpcResponse(); | 339 | return new XmlRpcResponse(); |
@@ -324,50 +345,50 @@ namespace OpenSim | |||
324 | return "OK"; | 345 | return "OK"; |
325 | }); | 346 | }); |
326 | } | 347 | } |
348 | } | ||
327 | 349 | ||
328 | LoginServer loginServer = null; | 350 | protected virtual void ConnectToRemoteGridServer() |
329 | LoginServer adminLoginServer = null; | 351 | { |
330 | 352 | if (GridServers.GridServer.RequestConnection(regionData.SimUUID, regionData.IPListenAddr, (uint)regionData.IPListenPort)) | |
331 | bool sandBoxWithLoginServer = m_loginserver && m_sandbox; | ||
332 | if (sandBoxWithLoginServer) | ||
333 | { | 353 | { |
334 | loginServer = new LoginServer(gridServer, regionData.IPListenAddr, regionData.IPListenPort,regionData.RegionLocX, regionData.RegionLocY, this.user_accounts); | 354 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Success: Got a grid connection OK!"); |
335 | loginServer.Startup(); | 355 | } |
336 | 356 | else | |
337 | if (user_accounts) | 357 | { |
338 | { | 358 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, "Main.cs:Startup() - FAILED: Unable to get connection to grid. Shutting down."); |
339 | //sandbox mode with loginserver using accounts | 359 | Shutdown(); |
340 | this.GridServers.UserServer = loginServer; | ||
341 | adminLoginServer = loginServer; | ||
342 | |||
343 | httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod); | ||
344 | } | ||
345 | else | ||
346 | { | ||
347 | //sandbox mode with loginserver not using accounts | ||
348 | httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod); | ||
349 | } | ||
350 | } | 360 | } |
351 | 361 | ||
352 | AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer); | 362 | GridServers.AssetServer.SetServerInfo((string)((RemoteGridBase)GridServers.GridServer).GridData["asset_url"], (string)((RemoteGridBase)GridServers.GridServer).GridData["asset_sendkey"]); |
353 | adminWebFront.LoadMethods(httpServer); | ||
354 | 363 | ||
355 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting HTTP server"); | 364 | // If we are being told to load a file, load it. |
356 | httpServer.Start(); | 365 | string dataUri = (string)((RemoteGridBase)GridServers.GridServer).GridData["data_uri"]; |
357 | 366 | ||
358 | if (gridServer.GetName() == "Remote") | 367 | if (!String.IsNullOrEmpty(dataUri)) |
359 | { | 368 | { |
360 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting up OGS protocol server"); | 369 | this.LocalWorld.m_datastore = dataUri; |
361 | OGSServer.Start(); | ||
362 | } | 370 | } |
363 | 371 | ||
364 | MainServerListener(); | 372 | if (((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString() != "") |
365 | 373 | { | |
366 | m_heartbeatTimer.Enabled = true; | 374 | // The grid server has told us who we are |
367 | m_heartbeatTimer.Interval = 100; | 375 | // We must obey the grid server. |
368 | m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat); | 376 | try |
377 | { | ||
378 | regionData.RegionLocX = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locx"].ToString()); | ||
379 | regionData.RegionLocY = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locy"].ToString()); | ||
380 | regionData.RegionName = ((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString(); | ||
381 | } | ||
382 | catch (Exception e) | ||
383 | { | ||
384 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, e.Message + "\nBAD ERROR! THIS SHOULD NOT HAPPEN! Bad GridData from the grid interface!!!! ZOMG!!!"); | ||
385 | Environment.Exit(1); | ||
386 | } | ||
387 | } | ||
369 | } | 388 | } |
370 | 389 | ||
390 | #endregion | ||
391 | |||
371 | private void SetupFromConfigFile(IGenericConfig configData) | 392 | private void SetupFromConfigFile(IGenericConfig configData) |
372 | { | 393 | { |
373 | try | 394 | try |
@@ -430,7 +451,7 @@ namespace OpenSim | |||
430 | switch (attri) | 451 | switch (attri) |
431 | { | 452 | { |
432 | default: | 453 | default: |
433 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,"Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating"); | 454 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating"); |
434 | Environment.Exit(1); | 455 | Environment.Exit(1); |
435 | break; | 456 | break; |
436 | 457 | ||
@@ -468,44 +489,7 @@ namespace OpenSim | |||
468 | } | 489 | } |
469 | } | 490 | } |
470 | 491 | ||
471 | private SimConfig LoadConfigDll(string dllName) | 492 | # region UDP |
472 | { | ||
473 | try | ||
474 | { | ||
475 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
476 | SimConfig config = null; | ||
477 | |||
478 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
479 | { | ||
480 | if (pluginType.IsPublic) | ||
481 | { | ||
482 | if (!pluginType.IsAbstract) | ||
483 | { | ||
484 | Type typeInterface = pluginType.GetInterface("ISimConfig", true); | ||
485 | |||
486 | if (typeInterface != null) | ||
487 | { | ||
488 | ISimConfig plug = (ISimConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
489 | config = plug.GetConfigObject(); | ||
490 | break; | ||
491 | } | ||
492 | |||
493 | typeInterface = null; | ||
494 | } | ||
495 | } | ||
496 | } | ||
497 | pluginAssembly = null; | ||
498 | return config; | ||
499 | } | ||
500 | catch (Exception e) | ||
501 | { | ||
502 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL,e.Message + "\nSorry, a fatal error occurred while trying to load the config DLL"); | ||
503 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL,"Can not continue starting up"); | ||
504 | Environment.Exit(1); | ||
505 | return null; | ||
506 | } | ||
507 | } | ||
508 | |||
509 | private void OnReceivedData(IAsyncResult result) | 493 | private void OnReceivedData(IAsyncResult result) |
510 | { | 494 | { |
511 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | 495 | ipeSender = new IPEndPoint(IPAddress.Any, 0); |
@@ -544,7 +528,7 @@ namespace OpenSim | |||
544 | this._packetServer.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser); | 528 | this._packetServer.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser); |
545 | 529 | ||
546 | //if (!((RemoteGridBase)GridServers.GridServer).agentcircuits[useCircuit.CircuitCode.Code].child) | 530 | //if (!((RemoteGridBase)GridServers.GridServer).agentcircuits[useCircuit.CircuitCode.Code].child) |
547 | 531 | ||
548 | 532 | ||
549 | } | 533 | } |
550 | else | 534 | else |
@@ -557,21 +541,21 @@ namespace OpenSim | |||
557 | 541 | ||
558 | private void MainServerListener() | 542 | private void MainServerListener() |
559 | { | 543 | { |
560 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:MainServerListener() - New thread started"); | 544 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:MainServerListener() - New thread started"); |
561 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:MainServerListener() - Opening UDP socket on " + regionData.IPListenAddr + ":" + regionData.IPListenPort); | 545 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:MainServerListener() - Opening UDP socket on " + regionData.IPListenAddr + ":" + regionData.IPListenPort); |
562 | 546 | ||
563 | ServerIncoming = new IPEndPoint(IPAddress.Any, regionData.IPListenPort); | 547 | ServerIncoming = new IPEndPoint(IPAddress.Any, regionData.IPListenPort); |
564 | Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | 548 | Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); |
565 | Server.Bind(ServerIncoming); | 549 | Server.Bind(ServerIncoming); |
566 | 550 | ||
567 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:MainServerListener() - UDP socket bound, getting ready to listen"); | 551 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:MainServerListener() - UDP socket bound, getting ready to listen"); |
568 | 552 | ||
569 | ipeSender = new IPEndPoint(IPAddress.Any, 0); | 553 | ipeSender = new IPEndPoint(IPAddress.Any, 0); |
570 | epSender = (EndPoint)ipeSender; | 554 | epSender = (EndPoint)ipeSender; |
571 | ReceivedData = new AsyncCallback(this.OnReceivedData); | 555 | ReceivedData = new AsyncCallback(this.OnReceivedData); |
572 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); | 556 | Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); |
573 | 557 | ||
574 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:MainServerListener() - Listening..."); | 558 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:MainServerListener() - Listening..."); |
575 | 559 | ||
576 | } | 560 | } |
577 | 561 | ||
@@ -611,16 +595,18 @@ namespace OpenSim | |||
611 | } | 595 | } |
612 | } | 596 | } |
613 | 597 | ||
598 | #endregion | ||
599 | |||
614 | /// <summary> | 600 | /// <summary> |
615 | /// Performs any last-minute sanity checking and shuts down the region server | 601 | /// Performs any last-minute sanity checking and shuts down the region server |
616 | /// </summary> | 602 | /// </summary> |
617 | public virtual void Shutdown() | 603 | public virtual void Shutdown() |
618 | { | 604 | { |
619 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Shutdown() - Closing all threads"); | 605 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing all threads"); |
620 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Shutdown() - Killing listener thread"); | 606 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing listener thread"); |
621 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Shutdown() - Killing clients"); | 607 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing clients"); |
622 | // IMPLEMENT THIS | 608 | // IMPLEMENT THIS |
623 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Shutdown() - Closing console and terminating"); | 609 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing console and terminating"); |
624 | LocalWorld.Close(); | 610 | LocalWorld.Close(); |
625 | GridServers.Close(); | 611 | GridServers.Close(); |
626 | m_console.Close(); | 612 | m_console.Close(); |
@@ -637,6 +623,7 @@ namespace OpenSim | |||
637 | LocalWorld.Update(); | 623 | LocalWorld.Update(); |
638 | } | 624 | } |
639 | 625 | ||
626 | #region Console Commands | ||
640 | /// <summary> | 627 | /// <summary> |
641 | /// Runs commands issued by the server console from the operator | 628 | /// Runs commands issued by the server console from the operator |
642 | /// </summary> | 629 | /// </summary> |
@@ -647,8 +634,8 @@ namespace OpenSim | |||
647 | switch (command) | 634 | switch (command) |
648 | { | 635 | { |
649 | case "help": | 636 | case "help": |
650 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"show users - show info about connected users"); | 637 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "show users - show info about connected users"); |
651 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"shutdown - disconnect all clients and shutdown"); | 638 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "shutdown - disconnect all clients and shutdown"); |
652 | break; | 639 | break; |
653 | 640 | ||
654 | case "show": | 641 | case "show": |
@@ -659,7 +646,7 @@ namespace OpenSim | |||
659 | string result = ""; | 646 | string result = ""; |
660 | if (!LocalWorld.Terrain.RunTerrainCmd(cmdparams, ref result)) | 647 | if (!LocalWorld.Terrain.RunTerrainCmd(cmdparams, ref result)) |
661 | { | 648 | { |
662 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,result); | 649 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, result); |
663 | } | 650 | } |
664 | break; | 651 | break; |
665 | 652 | ||
@@ -668,7 +655,7 @@ namespace OpenSim | |||
668 | break; | 655 | break; |
669 | 656 | ||
670 | default: | 657 | default: |
671 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"Unknown command"); | 658 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "Unknown command"); |
672 | break; | 659 | break; |
673 | } | 660 | } |
674 | } | 661 | } |
@@ -682,23 +669,24 @@ namespace OpenSim | |||
682 | switch (ShowWhat) | 669 | switch (ShowWhat) |
683 | { | 670 | { |
684 | case "uptime": | 671 | case "uptime": |
685 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"OpenSim has been running since " + startuptime.ToString()); | 672 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "OpenSim has been running since " + startuptime.ToString()); |
686 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"That is " + (DateTime.Now - startuptime).ToString()); | 673 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "That is " + (DateTime.Now - startuptime).ToString()); |
687 | break; | 674 | break; |
688 | case "users": | 675 | case "users": |
689 | OpenSim.world.Avatar TempAv; | 676 | OpenSim.world.Avatar TempAv; |
690 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP")); | 677 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP")); |
691 | foreach (libsecondlife.LLUUID UUID in LocalWorld.Entities.Keys) | 678 | foreach (libsecondlife.LLUUID UUID in LocalWorld.Entities.Keys) |
692 | { | 679 | { |
693 | if (LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar") | 680 | if (LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar") |
694 | { | 681 | { |
695 | TempAv = (OpenSim.world.Avatar)LocalWorld.Entities[UUID]; | 682 | TempAv = (OpenSim.world.Avatar)LocalWorld.Entities[UUID]; |
696 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString())); | 683 | m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString())); |
697 | } | 684 | } |
698 | } | 685 | } |
699 | break; | 686 | break; |
700 | } | 687 | } |
701 | } | 688 | } |
689 | #endregion | ||
702 | } | 690 | } |
703 | 691 | ||
704 | 692 | ||