aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/OpenSimMain.cs
diff options
context:
space:
mode:
authorMW2007-03-28 13:08:27 +0000
committerMW2007-03-28 13:08:27 +0000
commit98d81485e724b26d9ad35b9b7cd24c98808b9a81 (patch)
treee806f29235952264161fd33aab652937e84b1870 /OpenSim.RegionServer/OpenSimMain.cs
parent* And lo, the OpenSim (which is actually the RegionServer) is decoupled from ... (diff)
downloadopensim-SC_OLD-98d81485e724b26d9ad35b9b7cd24c98808b9a81.zip
opensim-SC_OLD-98d81485e724b26d9ad35b9b7cd24c98808b9a81.tar.gz
opensim-SC_OLD-98d81485e724b26d9ad35b9b7cd24c98808b9a81.tar.bz2
opensim-SC_OLD-98d81485e724b26d9ad35b9b7cd24c98808b9a81.tar.xz
RIP OpenSimRoot. (removed)
Merged most of the bug fixes etc in from LLdemo branch. Added the textures from that branch.
Diffstat (limited to 'OpenSim.RegionServer/OpenSimMain.cs')
-rw-r--r--OpenSim.RegionServer/OpenSimMain.cs99
1 files changed, 54 insertions, 45 deletions
diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs
index 497b801..ed3e732 100644
--- a/OpenSim.RegionServer/OpenSimMain.cs
+++ b/OpenSim.RegionServer/OpenSimMain.cs
@@ -48,10 +48,19 @@ using OpenSim.Physics.Manager;
48 48
49namespace OpenSim 49namespace OpenSim
50{ 50{
51 public class OpenSimMain : OpenSimApplication, conscmd_callback 51 public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback
52 { 52 {
53 private Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
54 private PhysicsManager physManager; 53 private PhysicsManager physManager;
54 private World LocalWorld;
55 private Grid GridServers;
56 private SimConfig Cfg;
57 private SimCAPSHTTPServer HttpServer;
58 private AssetCache AssetCache;
59 private InventoryCache InventoryCache;
60 //public Dictionary<EndPoint, SimClient> ClientThreads = new Dictionary<EndPoint, SimClient>();
61 private Dictionary<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>();
62 private Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
63 private DateTime startuptime;
55 64
56 public Socket Server; 65 public Socket Server;
57 private IPEndPoint ServerIncoming; 66 private IPEndPoint ServerIncoming;
@@ -79,68 +88,68 @@ namespace OpenSim
79 OpenSim.Framework.Console.MainConsole.Instance = m_console; 88 OpenSim.Framework.Console.MainConsole.Instance = m_console;
80 } 89 }
81 90
82 public override void StartUp() 91 public virtual void StartUp()
83 { 92 {
84 OpenSimRoot.Instance.GridServers = new Grid(); 93 GridServers = new Grid();
85 if ( m_sandbox ) 94 if ( m_sandbox )
86 { 95 {
87 OpenSimRoot.Instance.GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; 96 GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
88 OpenSimRoot.Instance.GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll"; 97 GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";
89 98
90 m_console.WriteLine("Starting in Sandbox mode"); 99 m_console.WriteLine("Starting in Sandbox mode");
91 } 100 }
92 else 101 else
93 { 102 {
94 OpenSimRoot.Instance.GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll"; 103 GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
95 OpenSimRoot.Instance.GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll"; 104 GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";
96 105
97 m_console.WriteLine("Starting in Grid mode"); 106 m_console.WriteLine("Starting in Grid mode");
98 } 107 }
99 108
100 OpenSimRoot.Instance.GridServers.Initialise(); 109 GridServers.Initialise();
101 110
102 OpenSimRoot.Instance.startuptime = DateTime.Now; 111 startuptime = DateTime.Now;
103 112
104 OpenSimRoot.Instance.AssetCache = new AssetCache(OpenSimRoot.Instance.GridServers.AssetServer); 113 AssetCache = new AssetCache(GridServers.AssetServer);
105 OpenSimRoot.Instance.InventoryCache = new InventoryCache(); 114 InventoryCache = new InventoryCache();
106 115
107 // We check our local database first, then the grid for config options 116 // We check our local database first, then the grid for config options
108 m_console.WriteLine("Main.cs:Startup() - Loading configuration"); 117 m_console.WriteLine("Main.cs:Startup() - Loading configuration");
109 OpenSimRoot.Instance.Cfg = this.LoadConfigDll(this.ConfigDll); 118 Cfg = this.LoadConfigDll(this.ConfigDll);
110 OpenSimRoot.Instance.Cfg.InitConfig(this.m_sandbox); 119 Cfg.InitConfig(this.m_sandbox);
111 m_console.WriteLine("Main.cs:Startup() - Contacting gridserver"); 120 m_console.WriteLine("Main.cs:Startup() - Contacting gridserver");
112 OpenSimRoot.Instance.Cfg.LoadFromGrid(); 121 Cfg.LoadFromGrid();
113 122
114 m_console.WriteLine("Main.cs:Startup() - We are " + OpenSimRoot.Instance.Cfg.RegionName + " at " + OpenSimRoot.Instance.Cfg.RegionLocX.ToString() + "," + OpenSimRoot.Instance.Cfg.RegionLocY.ToString()); 123 m_console.WriteLine("Main.cs:Startup() - We are " + Cfg.RegionName + " at " + Cfg.RegionLocX.ToString() + "," + Cfg.RegionLocY.ToString());
115 m_console.WriteLine("Initialising world"); 124 m_console.WriteLine("Initialising world");
116 OpenSimRoot.Instance.LocalWorld = new World(OpenSimRoot.Instance.ClientThreads, OpenSimRoot.Instance.Cfg.RegionHandle, OpenSimRoot.Instance.Cfg.RegionName, OpenSimRoot.Instance.Cfg); 125 LocalWorld = new World(ClientThreads, Cfg.RegionHandle, Cfg.RegionName, Cfg);
117 OpenSimRoot.Instance.LocalWorld.LandMap = OpenSimRoot.Instance.Cfg.LoadWorld(); 126 LocalWorld.LandMap = Cfg.LoadWorld();
118 127
119 this.physManager = new OpenSim.Physics.Manager.PhysicsManager(); 128 this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
120 this.physManager.LoadPlugins(); 129 this.physManager.LoadPlugins();
121 130
122 m_console.WriteLine("Main.cs:Startup() - Starting up messaging system"); 131 m_console.WriteLine("Main.cs:Startup() - Starting up messaging system");
123 OpenSimRoot.Instance.LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); //should be reading from the config file what physics engine to use 132 LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); //should be reading from the config file what physics engine to use
124 OpenSimRoot.Instance.LocalWorld.PhysScene.SetTerrain(OpenSimRoot.Instance.LocalWorld.LandMap); 133 LocalWorld.PhysScene.SetTerrain(LocalWorld.LandMap);
125 134
126 OpenSimRoot.Instance.GridServers.AssetServer.SetServerInfo(OpenSimRoot.Instance.Cfg.AssetURL, OpenSimRoot.Instance.Cfg.AssetSendKey); 135 GridServers.AssetServer.SetServerInfo(Cfg.AssetURL, Cfg.AssetSendKey);
127 OpenSimRoot.Instance.GridServers.GridServer.SetServerInfo(OpenSimRoot.Instance.Cfg.GridURL, OpenSimRoot.Instance.Cfg.GridSendKey, OpenSimRoot.Instance.Cfg.GridRecvKey); 136 GridServers.GridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey);
128 137
129 OpenSimRoot.Instance.LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. 138 LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
130 OpenSimRoot.Instance.LocalWorld.LoadPrimsFromStorage(); 139 LocalWorld.LoadPrimsFromStorage();
131 140
132 if ( m_sandbox) 141 if ( m_sandbox)
133 { 142 {
134 OpenSimRoot.Instance.AssetCache.LoadDefaultTextureSet(); 143 AssetCache.LoadDefaultTextureSet();
135 } 144 }
136 145
137 m_console.WriteLine("Main.cs:Startup() - Starting CAPS HTTP server"); 146 m_console.WriteLine("Main.cs:Startup() - Starting CAPS HTTP server");
138 OpenSimRoot.Instance.HttpServer = new SimCAPSHTTPServer(OpenSimRoot.Instance.GridServers.GridServer, OpenSimRoot.Instance.Cfg.IPListenPort); 147 HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort);
139 OpenSimRoot.Instance.HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", OpenSimRoot.Instance.LocalWorld)); 148 HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld));
140 149
141 if ( m_loginserver && m_sandbox) 150 if ( m_loginserver && m_sandbox)
142 { 151 {
143 LoginServer loginServer = new LoginServer(OpenSimRoot.Instance.GridServers.GridServer, OpenSimRoot.Instance.Cfg.IPListenAddr, OpenSimRoot.Instance.Cfg.IPListenPort); 152 LoginServer loginServer = new LoginServer(GridServers.GridServer, Cfg.IPListenAddr, Cfg.IPListenPort);
144 loginServer.Startup(); 153 loginServer.Startup();
145 } 154 }
146 155
@@ -194,15 +203,15 @@ namespace OpenSim
194 // do we already have a circuit for this endpoint 203 // do we already have a circuit for this endpoint
195 if(this.clientCircuits.ContainsKey(epSender)) 204 if(this.clientCircuits.ContainsKey(epSender))
196 { 205 {
197 OpenSimRoot.Instance.ClientThreads[this.clientCircuits[epSender]].InPacket(packet); 206 ClientThreads[this.clientCircuits[epSender]].InPacket(packet);
198 } 207 }
199 else if (packet.Type == PacketType.UseCircuitCode) 208 else if (packet.Type == PacketType.UseCircuitCode)
200 { // new client 209 { // new client
201 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet; 210 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet;
202 this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); 211 this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
203 SimClient newuser = new SimClient(epSender, useCircuit, OpenSimRoot.Instance.LocalWorld, OpenSimRoot.Instance.ClientThreads, OpenSimRoot.Instance.AssetCache, OpenSimRoot.Instance.GridServers.GridServer, OpenSimRoot.Instance.Application, OpenSimRoot.Instance.InventoryCache, OpenSimRoot.Instance.Sandbox); 212 SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox);
204 //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser); 213 //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser);
205 OpenSimRoot.Instance.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser); 214 ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
206 } 215 }
207 else 216 else
208 { // invalid client 217 { // invalid client
@@ -214,9 +223,9 @@ namespace OpenSim
214 private void MainServerListener() 223 private void MainServerListener()
215 { 224 {
216 m_console.WriteLine("Main.cs:MainServerListener() - New thread started"); 225 m_console.WriteLine("Main.cs:MainServerListener() - New thread started");
217 m_console.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + OpenSimRoot.Instance.Cfg.IPListenAddr + ":" + OpenSimRoot.Instance.Cfg.IPListenPort); 226 m_console.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + Cfg.IPListenAddr + ":" + Cfg.IPListenPort);
218 227
219 ServerIncoming = new IPEndPoint(IPAddress.Any, OpenSimRoot.Instance.Cfg.IPListenPort); 228 ServerIncoming = new IPEndPoint(IPAddress.Any, Cfg.IPListenPort);
220 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); 229 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
221 Server.Bind(ServerIncoming); 230 Server.Bind(ServerIncoming);
222 231
@@ -231,7 +240,7 @@ namespace OpenSim
231 240
232 } 241 }
233 242
234 public override void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode )//EndPoint packetSender) 243 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode )//EndPoint packetSender)
235 { 244 {
236 // find the endpoint for this circuit 245 // find the endpoint for this circuit
237 EndPoint sendto = null; 246 EndPoint sendto = null;
@@ -250,7 +259,7 @@ namespace OpenSim
250 } 259 }
251 } 260 }
252 261
253 public override void RemoveClientCircuit(uint circuitcode) 262 public virtual void RemoveClientCircuit(uint circuitcode)
254 { 263 {
255 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits) 264 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits)
256 { 265 {
@@ -262,22 +271,22 @@ namespace OpenSim
262 } 271 }
263 } 272 }
264 273
265 public override void Shutdown() 274 public virtual void Shutdown()
266 { 275 {
267 m_console.WriteLine("Main.cs:Shutdown() - Closing all threads"); 276 m_console.WriteLine("Main.cs:Shutdown() - Closing all threads");
268 m_console.WriteLine("Main.cs:Shutdown() - Killing listener thread"); 277 m_console.WriteLine("Main.cs:Shutdown() - Killing listener thread");
269 m_console.WriteLine("Main.cs:Shutdown() - Killing clients"); 278 m_console.WriteLine("Main.cs:Shutdown() - Killing clients");
270 // IMPLEMENT THIS 279 // IMPLEMENT THIS
271 m_console.WriteLine("Main.cs:Shutdown() - Closing console and terminating"); 280 m_console.WriteLine("Main.cs:Shutdown() - Closing console and terminating");
272 OpenSimRoot.Instance.LocalWorld.Close(); 281 LocalWorld.Close();
273 OpenSimRoot.Instance.GridServers.Close(); 282 GridServers.Close();
274 m_console.Close(); 283 m_console.Close();
275 Environment.Exit(0); 284 Environment.Exit(0);
276 } 285 }
277 286
278 void Timer1Tick(object sender, System.EventArgs e) 287 void Timer1Tick(object sender, System.EventArgs e)
279 { 288 {
280 OpenSimRoot.Instance.LocalWorld.Update(); 289 LocalWorld.Update();
281 } 290 }
282 291
283 public void RunCmd(string command, string[] cmdparams) 292 public void RunCmd(string command, string[] cmdparams)
@@ -295,7 +304,7 @@ namespace OpenSim
295 break; 304 break;
296 305
297 case "regenerate": 306 case "regenerate":
298 OpenSimRoot.Instance.LocalWorld.RegenerateTerrain(); 307 LocalWorld.RegenerateTerrain();
299 break; 308 break;
300 309
301 case "shutdown": 310 case "shutdown":
@@ -309,17 +318,17 @@ namespace OpenSim
309 switch (ShowWhat) 318 switch (ShowWhat)
310 { 319 {
311 case "uptime": 320 case "uptime":
312 m_console.WriteLine("OpenSim has been running since " + OpenSimRoot.Instance.startuptime.ToString()); 321 m_console.WriteLine("OpenSim has been running since " + startuptime.ToString());
313 m_console.WriteLine("That is " + (DateTime.Now - OpenSimRoot.Instance.startuptime).ToString()); 322 m_console.WriteLine("That is " + (DateTime.Now - startuptime).ToString());
314 break; 323 break;
315 case "users": 324 case "users":
316 OpenSim.world.Avatar TempAv; 325 OpenSim.world.Avatar TempAv;
317 m_console.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP")); 326 m_console.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP"));
318 foreach (libsecondlife.LLUUID UUID in OpenSimRoot.Instance.LocalWorld.Entities.Keys) 327 foreach (libsecondlife.LLUUID UUID in LocalWorld.Entities.Keys)
319 { 328 {
320 if (OpenSimRoot.Instance.LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar") 329 if (LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar")
321 { 330 {
322 TempAv = (OpenSim.world.Avatar)OpenSimRoot.Instance.LocalWorld.Entities[UUID]; 331 TempAv = (OpenSim.world.Avatar)LocalWorld.Entities[UUID];
323 m_console.WriteLine(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())); 332 m_console.WriteLine(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()));
324 } 333 }
325 } 334 }