More refactoring

0.1-prestable
MW 2007-04-01 20:42:42 +00:00
parent 86f6a33bc8
commit f48aabd1b1
6 changed files with 131 additions and 70 deletions

View File

@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
@ -6,7 +6,8 @@
<ProjectGuid>{632E1BFD-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.RegionServer</AssemblyName>
@ -15,9 +16,11 @@
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<AppDesignerFolder>
</AppDesignerFolder>
<RootNamespace>OpenSim.RegionServer</RootNamespace>
<StartupObject></StartupObject>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
@ -28,7 +31,8 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
@ -37,7 +41,8 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
<NoWarn>
</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@ -46,7 +51,8 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
@ -55,26 +61,28 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
<NoWarn>
</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<Reference Include="System">
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<Reference Include="System.Data" />
<Reference Include="System.Xml">
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll" >
<Reference Include="libsecondlife.dll">
<HintPath>..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Axiom.MathLib.dll" >
<Reference Include="Axiom.MathLib.dll">
<HintPath>..\bin\Axiom.MathLib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Db4objects.Db4o.dll" >
<Reference Include="Db4objects.Db4o.dll">
<HintPath>..\bin\Db4objects.Db4o.dll</HintPath>
<Private>False</Private>
</Reference>
@ -84,25 +92,25 @@
<Name>OpenSim.Framework</Name>
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
<Name>OpenSim.Framework.Console</Name>
<Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj">
<Name>OpenSim.Physics.Manager</Name>
<Project>{8BE16150-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\Servers\OpenSim.Servers.csproj">
<Name>OpenSim.Servers</Name>
<Project>{8BB20F0A-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
@ -121,6 +129,7 @@
<Compile Include="OpenSimNetworkHandler.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="PacketServer.cs" />
<Compile Include="QueItem.cs">
<SubType>Code</SubType>
</Compile>
@ -180,4 +189,4 @@
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
</Project>

View File

@ -16,6 +16,7 @@
<include name="Grid.cs" />
<include name="OpenSimMain.cs" />
<include name="OpenSimNetworkHandler.cs" />
<include name="PacketServer.cs" />
<include name="QueItem.cs" />
<include name="SimClient.cs" />
<include name="SimConsole.cs" />

View File

@ -53,16 +53,15 @@ namespace OpenSim
public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback
{
private PhysicsManager physManager;
private World LocalWorld;
private Grid GridServers;
private SimConfig Cfg;
//private SimCAPSHTTPServer HttpServer;
private BaseHttpServer HttpServer;
private PhysicsManager physManager;
private Grid GridServers;
private BaseHttpServer _httpServer;
private PacketServer _packetServer;
private World LocalWorld;
private AssetCache AssetCache;
private InventoryCache InventoryCache;
//public Dictionary<EndPoint, SimClient> ClientThreads = new Dictionary<EndPoint, SimClient>();
private Dictionary<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>();
//private Dictionary<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>();
private Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
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
}

View File

@ -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);
}
}

View File

@ -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<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>();
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
}
}

View File

@ -38,6 +38,7 @@ namespace OpenSim
if (args[i] == "-realphysx")
{
physicsEngine = "RealPhysX";
allowFlying = true;
}
if (args[i] == "-ode")
{