aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/OpenSimMain.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim.RegionServer/OpenSimMain.cs77
1 files changed, 26 insertions, 51 deletions
diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs
index f004f91..74b9e44 100644
--- a/OpenSim.RegionServer/OpenSimMain.cs
+++ b/OpenSim.RegionServer/OpenSimMain.cs
@@ -53,16 +53,15 @@ namespace OpenSim
53 53
54 public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback 54 public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback
55 { 55 {
56 private SimConfig Cfg;
56 private PhysicsManager physManager; 57 private PhysicsManager physManager;
57 private World LocalWorld;
58 private Grid GridServers; 58 private Grid GridServers;
59 private SimConfig Cfg; 59 private BaseHttpServer _httpServer;
60 //private SimCAPSHTTPServer HttpServer; 60 private PacketServer _packetServer;
61 private BaseHttpServer HttpServer; 61 private World LocalWorld;
62 private AssetCache AssetCache; 62 private AssetCache AssetCache;
63 private InventoryCache InventoryCache; 63 private InventoryCache InventoryCache;
64 //public Dictionary<EndPoint, SimClient> ClientThreads = new Dictionary<EndPoint, SimClient>(); 64 //private Dictionary<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>();
65 private Dictionary<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>();
66 private Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); 65 private Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
67 private DateTime startuptime; 66 private DateTime startuptime;
68 67
@@ -125,13 +124,18 @@ namespace OpenSim
125 m_console.WriteLine("Main.cs:Startup() - Contacting gridserver"); 124 m_console.WriteLine("Main.cs:Startup() - Contacting gridserver");
126 Cfg.LoadFromGrid(); 125 Cfg.LoadFromGrid();
127 126
127 PacketServer packetServer = new PacketServer(this);
128
128 m_console.WriteLine("Main.cs:Startup() - We are " + Cfg.RegionName + " at " + Cfg.RegionLocX.ToString() + "," + Cfg.RegionLocY.ToString()); 129 m_console.WriteLine("Main.cs:Startup() - We are " + Cfg.RegionName + " at " + Cfg.RegionLocX.ToString() + "," + Cfg.RegionLocY.ToString());
129 m_console.WriteLine("Initialising world"); 130 m_console.WriteLine("Initialising world");
130 LocalWorld = new World(ClientThreads, Cfg.RegionHandle, Cfg.RegionName, Cfg); 131 LocalWorld = new World(this._packetServer.ClientThreads, Cfg.RegionHandle, Cfg.RegionName, Cfg);
131 LocalWorld.LandMap = Cfg.LoadWorld(); 132 LocalWorld.LandMap = Cfg.LoadWorld();
132 LocalWorld.InventoryCache = InventoryCache; 133 LocalWorld.InventoryCache = InventoryCache;
133 LocalWorld.AssetCache = AssetCache; 134 LocalWorld.AssetCache = AssetCache;
134 135
136 this._packetServer.LocalWorld = LocalWorld;
137 this._packetServer.RegisterClientPacketHandlers();
138
135 this.physManager = new OpenSim.Physics.Manager.PhysicsManager(); 139 this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
136 this.physManager.LoadPlugins(); 140 this.physManager.LoadPlugins();
137 141
@@ -152,16 +156,14 @@ namespace OpenSim
152 AssetCache.LoadDefaultTextureSet(); 156 AssetCache.LoadDefaultTextureSet();
153 } 157 }
154 158
155 RegisterClientPacketHandlers();
156
157 m_console.WriteLine("Main.cs:Startup() - Initialising HTTP server"); 159 m_console.WriteLine("Main.cs:Startup() - Initialising HTTP server");
158 // HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort); 160 // HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort);
159 HttpServer = new BaseHttpServer(Cfg.IPListenPort); 161 _httpServer = new BaseHttpServer(Cfg.IPListenPort);
160 162
161 if (gridServer.GetName() == "Remote") 163 if (gridServer.GetName() == "Remote")
162 { 164 {
163 //we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server 165 //we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server
164 HttpServer.AddXmlRPCHandler("expect_user", 166 _httpServer.AddXmlRPCHandler("expect_user",
165 delegate(XmlRpcRequest request) 167 delegate(XmlRpcRequest request)
166 { 168 {
167 Hashtable requestData = (Hashtable)request.Params[0]; 169 Hashtable requestData = (Hashtable)request.Params[0];
@@ -179,7 +181,6 @@ namespace OpenSim
179 }); 181 });
180 } 182 }
181 183
182
183 LoginServer loginServer = null; 184 LoginServer loginServer = null;
184 LoginServer adminLoginServer = null; 185 LoginServer adminLoginServer = null;
185 186
@@ -195,20 +196,20 @@ namespace OpenSim
195 this.GridServers.UserServer = loginServer; 196 this.GridServers.UserServer = loginServer;
196 adminLoginServer = loginServer; 197 adminLoginServer = loginServer;
197 198
198 HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod); 199 _httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
199 } 200 }
200 else 201 else
201 { 202 {
202 //sandbox mode with loginserver not using accounts 203 //sandbox mode with loginserver not using accounts
203 HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod); 204 _httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
204 } 205 }
205 } 206 }
206 207
207 AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer); 208 AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer);
208 adminWebFront.LoadMethods( HttpServer ); 209 adminWebFront.LoadMethods( _httpServer );
209 210
210 m_console.WriteLine("Main.cs:Startup() - Starting HTTP server"); 211 m_console.WriteLine("Main.cs:Startup() - Starting HTTP server");
211 HttpServer.Start(); 212 _httpServer.Start();
212 213
213 MainServerListener(); 214 MainServerListener();
214 215
@@ -260,19 +261,20 @@ namespace OpenSim
260 // do we already have a circuit for this endpoint 261 // do we already have a circuit for this endpoint
261 if (this.clientCircuits.ContainsKey(epSender)) 262 if (this.clientCircuits.ContainsKey(epSender))
262 { 263 {
263 ClientThreads[this.clientCircuits[epSender]].InPacket(packet); 264 //ClientThreads[this.clientCircuits[epSender]].InPacket(packet);
265 this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet);
264 } 266 }
265 else if (packet.Type == PacketType.UseCircuitCode) 267 else if (packet.Type == PacketType.UseCircuitCode)
266 { // new client 268 { // new client
267 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet; 269 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet;
268 this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); 270 this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
269 SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox); 271 SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, _packetServer.ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox);
270 if ((this.GridServers.UserServer != null) && (user_accounts)) 272 if ((this.GridServers.UserServer != null) && (user_accounts))
271 { 273 {
272 newuser.UserServer = this.GridServers.UserServer; 274 newuser.UserServer = this.GridServers.UserServer;
273 } 275 }
274 //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser); 276 //OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser);
275 ClientThreads.Add(useCircuit.CircuitCode.Code, newuser); 277 this._packetServer.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
276 } 278 }
277 else 279 else
278 { // invalid client 280 { // invalid client
@@ -301,6 +303,11 @@ namespace OpenSim
301 303
302 } 304 }
303 305
306 public void RegisterPacketServer(PacketServer server)
307 {
308 this._packetServer = server;
309 }
310
304 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender) 311 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender)
305 { 312 {
306 // find the endpoint for this circuit 313 // find the endpoint for this circuit
@@ -396,38 +403,6 @@ namespace OpenSim
396 break; 403 break;
397 } 404 }
398 } 405 }
399
400 protected virtual void RegisterClientPacketHandlers()
401 {
402 SimClient.AddPacketHandler(PacketType.ModifyLand, LocalWorld.ModifyTerrain);
403 SimClient.AddPacketHandler(PacketType.ChatFromViewer, LocalWorld.SimChat);
404 SimClient.AddPacketHandler(PacketType.RezObject, LocalWorld.RezObject);
405 SimClient.AddPacketHandler(PacketType.DeRezObject, LocalWorld.DeRezObject);
406 SimClient.AddPacketHandler(PacketType.UUIDNameRequest, this.RequestUUIDName);
407 }
408
409 #region Client Packet Handlers
410
411 public bool RequestUUIDName(SimClient simClient, Packet packet)
412 {
413 System.Text.Encoding enc = System.Text.Encoding.ASCII;
414 Console.WriteLine(packet.ToString());
415 UUIDNameRequestPacket nameRequest = (UUIDNameRequestPacket)packet;
416 UUIDNameReplyPacket nameReply = new UUIDNameReplyPacket();
417 nameReply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[nameRequest.UUIDNameBlock.Length];
418
419 for (int i = 0; i < nameRequest.UUIDNameBlock.Length; i++)
420 {
421 nameReply.UUIDNameBlock[i] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
422 nameReply.UUIDNameBlock[i].ID = nameRequest.UUIDNameBlock[i].ID;
423 nameReply.UUIDNameBlock[i].FirstName = enc.GetBytes("Who\0"); //for now send any name
424 nameReply.UUIDNameBlock[i].LastName = enc.GetBytes("Knows\0"); //in future need to look it up
425 }
426 simClient.OutPacket(nameReply);
427 return true;
428 }
429
430 #endregion
431 } 406 }
432 407
433 408