From f48aabd1b163fcb19d49748dc2f0c33aa277b091 Mon Sep 17 00:00:00 2001
From: MW
Date: Sun, 1 Apr 2007 20:42:42 +0000
Subject: More refactoring
---
OpenSim.RegionServer/OpenSim.RegionServer.csproj | 45 ++++++++-----
.../OpenSim.RegionServer.dll.build | 1 +
OpenSim.RegionServer/OpenSimMain.cs | 77 ++++++++--------------
OpenSim.RegionServer/OpenSimNetworkHandler.cs | 1 +
OpenSim.RegionServer/PacketServer.cs | 74 +++++++++++++++++++++
5 files changed, 129 insertions(+), 69 deletions(-)
create mode 100644 OpenSim.RegionServer/PacketServer.cs
(limited to 'OpenSim.RegionServer')
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj
index bd9ffb6..df66b48 100644
--- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj
+++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj
@@ -1,4 +1,4 @@
-
+
Local
8.0.50727
@@ -6,7 +6,8 @@
{632E1BFD-0000-0000-0000-000000000000}
Debug
AnyCPU
-
+
+
OpenSim.RegionServer
@@ -15,9 +16,11 @@
IE50
false
Library
-
+
+
OpenSim.RegionServer
-
+
+
@@ -28,7 +31,8 @@
TRACE;DEBUG
-
+
+
True
4096
False
@@ -37,7 +41,8 @@
False
False
4
-
+
+
False
@@ -46,7 +51,8 @@
TRACE
-
+
+
False
4096
True
@@ -55,26 +61,28 @@
False
False
4
-
+
+
-
+
System.dll
False
-
+
+
System.Xml.dll
False
-
+
..\bin\libsecondlife.dll
False
-
+
..\bin\Axiom.MathLib.dll
False
-
+
..\bin\Db4objects.Db4o.dll
False
@@ -84,25 +92,25 @@
OpenSim.Framework
{8ACA2445-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Framework.Console
{A7CD0630-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Physics.Manager
{8BE16150-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Servers
{8BB20F0A-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
@@ -121,6 +129,7 @@
Code
+
Code
@@ -180,4 +189,4 @@
-
+
\ No newline at end of file
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
index 5e29b48..6f86970 100644
--- a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
+++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
@@ -16,6 +16,7 @@
+
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
public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback
{
+ private SimConfig Cfg;
private PhysicsManager physManager;
- private World LocalWorld;
private Grid GridServers;
- private SimConfig Cfg;
- //private SimCAPSHTTPServer HttpServer;
- private BaseHttpServer HttpServer;
+ private BaseHttpServer _httpServer;
+ private PacketServer _packetServer;
+ private World LocalWorld;
private AssetCache AssetCache;
private InventoryCache InventoryCache;
- //public Dictionary ClientThreads = new Dictionary();
- private Dictionary ClientThreads = new Dictionary();
+ //private Dictionary ClientThreads = new Dictionary();
private Dictionary clientCircuits = new Dictionary();
private DateTime startuptime;
@@ -125,13 +124,18 @@ namespace OpenSim
m_console.WriteLine("Main.cs:Startup() - Contacting gridserver");
Cfg.LoadFromGrid();
+ PacketServer packetServer = new PacketServer(this);
+
m_console.WriteLine("Main.cs:Startup() - We are " + Cfg.RegionName + " at " + Cfg.RegionLocX.ToString() + "," + Cfg.RegionLocY.ToString());
m_console.WriteLine("Initialising world");
- LocalWorld = new World(ClientThreads, Cfg.RegionHandle, Cfg.RegionName, Cfg);
+ LocalWorld = new World(this._packetServer.ClientThreads, Cfg.RegionHandle, Cfg.RegionName, Cfg);
LocalWorld.LandMap = Cfg.LoadWorld();
LocalWorld.InventoryCache = InventoryCache;
LocalWorld.AssetCache = AssetCache;
+ this._packetServer.LocalWorld = LocalWorld;
+ this._packetServer.RegisterClientPacketHandlers();
+
this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
this.physManager.LoadPlugins();
@@ -152,16 +156,14 @@ namespace OpenSim
AssetCache.LoadDefaultTextureSet();
}
- RegisterClientPacketHandlers();
-
m_console.WriteLine("Main.cs:Startup() - Initialising HTTP server");
// HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort);
- HttpServer = new BaseHttpServer(Cfg.IPListenPort);
+ _httpServer = new BaseHttpServer(Cfg.IPListenPort);
if (gridServer.GetName() == "Remote")
{
//we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server
- HttpServer.AddXmlRPCHandler("expect_user",
+ _httpServer.AddXmlRPCHandler("expect_user",
delegate(XmlRpcRequest request)
{
Hashtable requestData = (Hashtable)request.Params[0];
@@ -179,7 +181,6 @@ namespace OpenSim
});
}
-
LoginServer loginServer = null;
LoginServer adminLoginServer = null;
@@ -195,20 +196,20 @@ namespace OpenSim
this.GridServers.UserServer = loginServer;
adminLoginServer = loginServer;
- HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
+ _httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
}
else
{
//sandbox mode with loginserver not using accounts
- HttpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
+ _httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
}
}
AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer);
- adminWebFront.LoadMethods( HttpServer );
+ adminWebFront.LoadMethods( _httpServer );
m_console.WriteLine("Main.cs:Startup() - Starting HTTP server");
- HttpServer.Start();
+ _httpServer.Start();
MainServerListener();
@@ -260,19 +261,20 @@ namespace OpenSim
// do we already have a circuit for this endpoint
if (this.clientCircuits.ContainsKey(epSender))
{
- ClientThreads[this.clientCircuits[epSender]].InPacket(packet);
+ //ClientThreads[this.clientCircuits[epSender]].InPacket(packet);
+ this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet);
}
else if (packet.Type == PacketType.UseCircuitCode)
{ // new client
UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet;
this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
- SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox);
+ SimClient newuser = new SimClient(epSender, useCircuit, LocalWorld, _packetServer.ClientThreads, AssetCache, GridServers.GridServer, this, InventoryCache, m_sandbox);
if ((this.GridServers.UserServer != null) && (user_accounts))
{
newuser.UserServer = this.GridServers.UserServer;
}
//OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser);
- ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
+ this._packetServer.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
}
else
{ // invalid client
@@ -301,6 +303,11 @@ namespace OpenSim
}
+ public void RegisterPacketServer(PacketServer server)
+ {
+ this._packetServer = server;
+ }
+
public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender)
{
// find the endpoint for this circuit
@@ -396,38 +403,6 @@ namespace OpenSim
break;
}
}
-
- protected virtual void RegisterClientPacketHandlers()
- {
- SimClient.AddPacketHandler(PacketType.ModifyLand, LocalWorld.ModifyTerrain);
- SimClient.AddPacketHandler(PacketType.ChatFromViewer, LocalWorld.SimChat);
- SimClient.AddPacketHandler(PacketType.RezObject, LocalWorld.RezObject);
- SimClient.AddPacketHandler(PacketType.DeRezObject, LocalWorld.DeRezObject);
- SimClient.AddPacketHandler(PacketType.UUIDNameRequest, this.RequestUUIDName);
- }
-
- #region Client Packet Handlers
-
- public bool RequestUUIDName(SimClient simClient, Packet packet)
- {
- System.Text.Encoding enc = System.Text.Encoding.ASCII;
- Console.WriteLine(packet.ToString());
- UUIDNameRequestPacket nameRequest = (UUIDNameRequestPacket)packet;
- UUIDNameReplyPacket nameReply = new UUIDNameReplyPacket();
- nameReply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[nameRequest.UUIDNameBlock.Length];
-
- for (int i = 0; i < nameRequest.UUIDNameBlock.Length; i++)
- {
- nameReply.UUIDNameBlock[i] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
- nameReply.UUIDNameBlock[i].ID = nameRequest.UUIDNameBlock[i].ID;
- nameReply.UUIDNameBlock[i].FirstName = enc.GetBytes("Who\0"); //for now send any name
- nameReply.UUIDNameBlock[i].LastName = enc.GetBytes("Knows\0"); //in future need to look it up
- }
- simClient.OutPacket(nameReply);
- return true;
- }
-
- #endregion
}
diff --git a/OpenSim.RegionServer/OpenSimNetworkHandler.cs b/OpenSim.RegionServer/OpenSimNetworkHandler.cs
index 4ed201e..6649120 100644
--- a/OpenSim.RegionServer/OpenSimNetworkHandler.cs
+++ b/OpenSim.RegionServer/OpenSimNetworkHandler.cs
@@ -12,5 +12,6 @@ namespace OpenSim
// public abstract void Shutdown();
void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender);
void RemoveClientCircuit(uint circuitcode);
+ void RegisterPacketServer(PacketServer server);
}
}
diff --git a/OpenSim.RegionServer/PacketServer.cs b/OpenSim.RegionServer/PacketServer.cs
new file mode 100644
index 0000000..af0382c
--- /dev/null
+++ b/OpenSim.RegionServer/PacketServer.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenSim.world;
+using libsecondlife.Packets;
+
+namespace OpenSim
+{
+ public class PacketServer
+ {
+ private OpenSimNetworkHandler _networkHandler;
+ private World _localWorld;
+ public Dictionary ClientThreads = new Dictionary();
+
+ public PacketServer(OpenSimNetworkHandler networkHandler)
+ {
+ _networkHandler = networkHandler;
+ _networkHandler.RegisterPacketServer(this);
+ }
+
+ public World LocalWorld
+ {
+ set
+ {
+ this._localWorld = value;
+ }
+ }
+
+ public void ClientInPacket(uint circuitCode, Packet packet)
+ {
+ if (this.ClientThreads.ContainsKey(circuitCode))
+ {
+ ClientThreads[circuitCode].InPacket(packet);
+ }
+ }
+
+ public bool AddNewCircuitCodeClient(uint circuitCode)
+ {
+ return false;
+ }
+
+ public virtual void RegisterClientPacketHandlers()
+ {
+ SimClient.AddPacketHandler(PacketType.ModifyLand, _localWorld.ModifyTerrain);
+ SimClient.AddPacketHandler(PacketType.ChatFromViewer, _localWorld.SimChat);
+ SimClient.AddPacketHandler(PacketType.RezObject, _localWorld.RezObject);
+ SimClient.AddPacketHandler(PacketType.DeRezObject, _localWorld.DeRezObject);
+ SimClient.AddPacketHandler(PacketType.UUIDNameRequest, this.RequestUUIDName);
+ }
+
+ #region Client Packet Handlers
+
+ public bool RequestUUIDName(SimClient simClient, Packet packet)
+ {
+ System.Text.Encoding enc = System.Text.Encoding.ASCII;
+ Console.WriteLine(packet.ToString());
+ UUIDNameRequestPacket nameRequest = (UUIDNameRequestPacket)packet;
+ UUIDNameReplyPacket nameReply = new UUIDNameReplyPacket();
+ nameReply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[nameRequest.UUIDNameBlock.Length];
+
+ for (int i = 0; i < nameRequest.UUIDNameBlock.Length; i++)
+ {
+ nameReply.UUIDNameBlock[i] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
+ nameReply.UUIDNameBlock[i].ID = nameRequest.UUIDNameBlock[i].ID;
+ nameReply.UUIDNameBlock[i].FirstName = enc.GetBytes("Who\0"); //for now send any name
+ nameReply.UUIDNameBlock[i].LastName = enc.GetBytes("Knows\0"); //in future need to look it up
+ }
+ simClient.OutPacket(nameReply);
+ return true;
+ }
+
+ #endregion
+ }
+}
--
cgit v1.1