aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/OpenSimMain.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim.RegionServer/OpenSimMain.cs')
-rw-r--r--OpenSim.RegionServer/OpenSimMain.cs86
1 files changed, 63 insertions, 23 deletions
diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs
index 07a2d6d..651c0c6 100644
--- a/OpenSim.RegionServer/OpenSimMain.cs
+++ b/OpenSim.RegionServer/OpenSimMain.cs
@@ -45,6 +45,8 @@ using OpenSim.Assets;
45using OpenSim.CAPS; 45using OpenSim.CAPS;
46using OpenSim.Framework.Console; 46using OpenSim.Framework.Console;
47using OpenSim.Physics.Manager; 47using OpenSim.Physics.Manager;
48using Nwc.XmlRpc;
49using OpenSim.Servers;
48 50
49namespace OpenSim 51namespace OpenSim
50{ 52{
@@ -54,7 +56,8 @@ namespace OpenSim
54 private World LocalWorld; 56 private World LocalWorld;
55 private Grid GridServers; 57 private Grid GridServers;
56 private SimConfig Cfg; 58 private SimConfig Cfg;
57 private SimCAPSHTTPServer HttpServer; 59 //private SimCAPSHTTPServer HttpServer;
60 private BaseHttpServer HttpServer;
58 private AssetCache AssetCache; 61 private AssetCache AssetCache;
59 private InventoryCache InventoryCache; 62 private InventoryCache InventoryCache;
60 //public Dictionary<EndPoint, SimClient> ClientThreads = new Dictionary<EndPoint, SimClient>(); 63 //public Dictionary<EndPoint, SimClient> ClientThreads = new Dictionary<EndPoint, SimClient>();
@@ -78,13 +81,13 @@ namespace OpenSim
78 public bool user_accounts = false; 81 public bool user_accounts = false;
79 82
80 protected ConsoleBase m_console; 83 protected ConsoleBase m_console;
81 84
82 public OpenSimMain( bool sandBoxMode, bool startLoginServer, string physicsEngine ) 85 public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine)
83 { 86 {
84 m_sandbox = sandBoxMode; 87 m_sandbox = sandBoxMode;
85 m_loginserver = startLoginServer; 88 m_loginserver = startLoginServer;
86 m_physicsEngine = physicsEngine; 89 m_physicsEngine = physicsEngine;
87 90
88 m_console = new ConsoleBase("region-console.log", "Region", this); 91 m_console = new ConsoleBase("region-console.log", "Region", this);
89 OpenSim.Framework.Console.MainConsole.Instance = m_console; 92 OpenSim.Framework.Console.MainConsole.Instance = m_console;
90 } 93 }
@@ -92,11 +95,11 @@ namespace OpenSim
92 public virtual void StartUp() 95 public virtual void StartUp()
93 { 96 {
94 GridServers = new Grid(); 97 GridServers = new Grid();
95 if ( m_sandbox ) 98 if (m_sandbox)
96 { 99 {
97 GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll"; 100 GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
98 GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll"; 101 GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";
99 102
100 m_console.WriteLine("Starting in Sandbox mode"); 103 m_console.WriteLine("Starting in Sandbox mode");
101 } 104 }
102 else 105 else
@@ -108,7 +111,7 @@ namespace OpenSim
108 } 111 }
109 112
110 GridServers.Initialise(); 113 GridServers.Initialise();
111 114
112 startuptime = DateTime.Now; 115 startuptime = DateTime.Now;
113 116
114 AssetCache = new AssetCache(GridServers.AssetServer); 117 AssetCache = new AssetCache(GridServers.AssetServer);
@@ -134,36 +137,74 @@ namespace OpenSim
134 LocalWorld.PhysScene.SetTerrain(LocalWorld.LandMap); 137 LocalWorld.PhysScene.SetTerrain(LocalWorld.LandMap);
135 138
136 GridServers.AssetServer.SetServerInfo(Cfg.AssetURL, Cfg.AssetSendKey); 139 GridServers.AssetServer.SetServerInfo(Cfg.AssetURL, Cfg.AssetSendKey);
137 GridServers.GridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey); 140 //GridServers.GridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey);
141 IGridServer gridServer = GridServers.GridServer;
142 gridServer.SetServerInfo(Cfg.GridURL, Cfg.GridSendKey, Cfg.GridRecvKey);
138 143
139 LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded. 144 LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
140 LocalWorld.LoadPrimsFromStorage(); 145 LocalWorld.LoadPrimsFromStorage();
141 146
142 if ( m_sandbox) 147 if (m_sandbox)
143 { 148 {
144 AssetCache.LoadDefaultTextureSet(); 149 AssetCache.LoadDefaultTextureSet();
145 } 150 }
146 151
147 m_console.WriteLine("Main.cs:Startup() - Starting CAPS HTTP server"); 152 m_console.WriteLine("Main.cs:Startup() - Initialising HTTP server");
148 HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort); 153 // HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort);
154 HttpServer = new BaseHttpServer(Cfg.IPListenPort);
155
156 if (gridServer.GetName() == "Remote")
157 {
158 //we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server
159 HttpServer.AddXmlRPCHandler("expect_user",
160 delegate(XmlRpcRequest request)
161 {
162 Hashtable requestData = (Hashtable)request.Params[0];
163 AgentCircuitData agent_data = new AgentCircuitData();
164 agent_data.SessionID = new LLUUID((string)requestData["session_id"]);
165 agent_data.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
166 agent_data.firstname = (string)requestData["firstname"];
167 agent_data.lastname = (string)requestData["lastname"];
168 agent_data.AgentID = new LLUUID((string)requestData["agent_id"]);
169 agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
170
171 ((RemoteGridBase)gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data);
172
173 return new XmlRpcResponse();
174 });
175 }
176
149 177
150 LoginServer loginServer = null; 178 LoginServer loginServer = null;
151 if (m_loginserver && m_sandbox) 179 if (m_loginserver && m_sandbox)
152 { 180 {
153 loginServer = new LoginServer(GridServers.GridServer, Cfg.IPListenAddr, Cfg.IPListenPort, this.user_accounts); 181 loginServer = new LoginServer(gridServer, Cfg.IPListenAddr, Cfg.IPListenPort, this.user_accounts);
154 loginServer.Startup(); 182 loginServer.Startup();
155 183
156 } 184 }
157 if((m_loginserver) && (m_sandbox) && (user_accounts)) 185
186 if ((m_loginserver) && (m_sandbox) && (user_accounts))
158 { 187 {
188 //sandbox mode with loginserver using accounts
159 this.GridServers.UserServer = loginServer; 189 this.GridServers.UserServer = loginServer;
160 HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, loginServer)); 190 HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, loginServer));
191 HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
161 } 192 }
162 else 193 else if ((m_loginserver) && (m_sandbox))
194 {
195 //sandbox mode with loginserver not using accounts
196 HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, null));
197 HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
198 }
199 else
163 { 200 {
201 //not in sandbox mode so no loginserver, so we don't handle login attempts
164 HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, null)); 202 HttpServer.AddRestHandler("Admin", new AdminWebFront("Admin", LocalWorld, null));
165 } 203 }
166 204
205 m_console.WriteLine("Main.cs:Startup() - Starting HTTP server");
206 HttpServer.Start();
207
167 MainServerListener(); 208 MainServerListener();
168 209
169 timer1.Enabled = true; 210 timer1.Enabled = true;
@@ -207,12 +248,12 @@ namespace OpenSim
207 int numBytes = Server.EndReceiveFrom(result, ref epSender); 248 int numBytes = Server.EndReceiveFrom(result, ref epSender);
208 int packetEnd = numBytes - 1; 249 int packetEnd = numBytes - 1;
209 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer); 250 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
210 251
211 // This is either a new client or a packet to send to an old one 252 // This is either a new client or a packet to send to an old one
212 // if (OpenSimRoot.Instance.ClientThreads.ContainsKey(epSender)) 253 // if (OpenSimRoot.Instance.ClientThreads.ContainsKey(epSender))
213 254
214 // do we already have a circuit for this endpoint 255 // do we already have a circuit for this endpoint
215 if(this.clientCircuits.ContainsKey(epSender)) 256 if (this.clientCircuits.ContainsKey(epSender))
216 { 257 {
217 ClientThreads[this.clientCircuits[epSender]].InPacket(packet); 258 ClientThreads[this.clientCircuits[epSender]].InPacket(packet);
218 } 259 }
@@ -223,7 +264,6 @@ namespace OpenSim
223 SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox); 264 SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox);
224 if ((this.GridServers.UserServer != null) && (user_accounts)) 265 if ((this.GridServers.UserServer != null) && (user_accounts))
225 { 266 {
226 Console.WriteLine("setting userserver");
227 newuser.UserServer = this.GridServers.UserServer; 267 newuser.UserServer = this.GridServers.UserServer;
228 } 268 }
229 //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser); 269 //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser);
@@ -256,11 +296,11 @@ namespace OpenSim
256 296
257 } 297 }
258 298
259 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode )//EndPoint packetSender) 299 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender)
260 { 300 {
261 // find the endpoint for this circuit 301 // find the endpoint for this circuit
262 EndPoint sendto = null; 302 EndPoint sendto = null;
263 foreach(KeyValuePair<EndPoint, uint> p in this.clientCircuits) 303 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits)
264 { 304 {
265 if (p.Value == circuitcode) 305 if (p.Value == circuitcode)
266 { 306 {
@@ -304,7 +344,7 @@ namespace OpenSim
304 { 344 {
305 LocalWorld.Update(); 345 LocalWorld.Update();
306 } 346 }
307 347
308 public void RunCmd(string command, string[] cmdparams) 348 public void RunCmd(string command, string[] cmdparams)
309 { 349 {
310 switch (command) 350 switch (command)
@@ -353,5 +393,5 @@ namespace OpenSim
353 } 393 }
354 } 394 }
355 395
356 396
357} 397}