started to refactor startup code and to move udp server code out to its own class (currently not being used though) so that a single instance can handle multiple regions (each will need to be listening on a separate udp port)

zircon^2
MW 2007-05-16 12:44:58 +00:00
parent 57d1a7bced
commit 3d93d39048
17 changed files with 616 additions and 471 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,13 +61,15 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
<NoWarn>
</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml">
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
@ -139,21 +147,23 @@
<Compile Include="PacketServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="QueItem.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="RegionInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SimClient(Grid).cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="RegionInfoBase.cs" />
<Compile Include="SimClient.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SimClientPacketHandlers.cs">
<Compile Include="SimClient.Grid.cs">
<SubType>Code</SubType>
<DependentUpon>SimClient.cs</DependentUpon>
</Compile>
<Compile Include="SimClient.PacketHandlers.cs">
<SubType>Code</SubType>
<DependentUpon>SimClient.cs</DependentUpon>
</Compile>
<Compile Include="SimClientBase.cs" />
<Compile Include="UDPServer.cs" />
<Compile Include="VersionInfo.cs">
<SubType>Code</SubType>
</Compile>
@ -172,18 +182,20 @@
<Compile Include="types\Triangle.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="world\Avatar.Client.cs">
<SubType>Code</SubType>
<DependentUpon>Avatar.cs</DependentUpon>
</Compile>
<Compile Include="world\Avatar.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="world\Avatar.Update.cs">
<SubType>Code</SubType>
<DependentUpon>Avatar.cs</DependentUpon>
</Compile>
<Compile Include="world\AvatarAnimations.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="world\AvatarClient.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="world\AvatarUpdate.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="world\Entity.cs">
<SubType>Code</SubType>
</Compile>
@ -199,11 +211,13 @@
<Compile Include="world\World.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="world\WorldPacketHandlers.cs">
<Compile Include="world\World.PacketHandlers.cs">
<SubType>Code</SubType>
<DependentUpon>World.cs</DependentUpon>
</Compile>
<Compile Include="world\WorldScripting.cs">
<Compile Include="world\World.Scripting.cs">
<SubType>Code</SubType>
<DependentUpon>World.cs</DependentUpon>
</Compile>
<Compile Include="world\scripting\IScriptContext.cs">
<SubType>Code</SubType>

View File

@ -16,28 +16,30 @@
<include name="OpenSimMain.cs" />
<include name="OpenSimNetworkHandler.cs" />
<include name="PacketServer.cs" />
<include name="QueItem.cs" />
<include name="RegionInfo.cs" />
<include name="SimClient(Grid).cs" />
<include name="RegionInfoBase.cs" />
<include name="SimClient.cs" />
<include name="SimClientPacketHandlers.cs" />
<include name="SimClient.Grid.cs" />
<include name="SimClient.PacketHandlers.cs" />
<include name="SimClientBase.cs" />
<include name="UDPServer.cs" />
<include name="VersionInfo.cs" />
<include name="Assets/AssetCache.cs" />
<include name="Assets/InventoryCache.cs" />
<include name="CAPS/AdminWebFront.cs" />
<include name="types/Mesh.cs" />
<include name="types/Triangle.cs" />
<include name="world/Avatar.Client.cs" />
<include name="world/Avatar.cs" />
<include name="world/Avatar.Update.cs" />
<include name="world/AvatarAnimations.cs" />
<include name="world/AvatarClient.cs" />
<include name="world/AvatarUpdate.cs" />
<include name="world/Entity.cs" />
<include name="world/Primitive.cs" />
<include name="world/Primitive2.cs" />
<include name="world/SceneObject.cs" />
<include name="world/World.cs" />
<include name="world/WorldPacketHandlers.cs" />
<include name="world/WorldScripting.cs" />
<include name="world/World.PacketHandlers.cs" />
<include name="world/World.Scripting.cs" />
<include name="world/scripting/IScriptContext.cs" />
<include name="world/scripting/IScriptEntity.cs" />
<include name="world/scripting/IScriptHandler.cs" />

View File

@ -56,7 +56,6 @@ namespace OpenSim
public class OpenSimMain : OpenSimNetworkHandler, conscmd_callback
{
//private SimConfig Cfg;
private IGenericConfig localConfig;
//private IGenericConfig remoteConfig;
private PhysicsManager physManager;
@ -65,7 +64,6 @@ namespace OpenSim
private World LocalWorld;
private AssetCache AssetCache;
private InventoryCache InventoryCache;
//private Dictionary<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>();
private Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
private DateTime startuptime;
private RegionInfo regionData;
@ -79,16 +77,16 @@ namespace OpenSim
private AsyncCallback ReceivedData;
private System.Timers.Timer m_heartbeatTimer = new System.Timers.Timer();
//private string ConfigDll = "OpenSim.Config.SimConfigDb4o.dll";
public string m_physicsEngine;
public bool m_sandbox = false;
public bool m_loginserver;
public OpenGridProtocolServer OGSServer;
public bool user_accounts = false;
public bool gridLocalAsset = false;
private bool configFileSetup = false;
public string m_config;
protected BaseHttpServer httpServer;
protected ConsoleBase m_console;
public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool verbose, string configFile)
@ -126,38 +124,14 @@ namespace OpenSim
this.regionData.InitConfig(this.m_sandbox, this.localConfig);
this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change
GridServers = new Grid();
if (m_sandbox)
{
GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Starting in Sandbox mode");
this.SetupLocalGridServers();
}
else
{
if (this.gridLocalAsset)
{
GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
}
else
{
GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
}
GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Starting in Grid mode");
}
try
{
GridServers.Initialise();
}
catch (Exception e)
{
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,e.Message + "\nSorry, could not setup the grid interface");
Environment.Exit(1);
this.SetupRemoteGridServers();
}
startuptime = DateTime.Now;
@ -175,13 +149,205 @@ namespace OpenSim
PacketServer packetServer = new PacketServer(this);
//should be passing a IGenericConfig object to these so they can read the config data they want from it
GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey);
IGridServer gridServer = GridServers.GridServer;
gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey);
if (!m_sandbox)
{
this.ConnectToRemoteGridServer();
}
this.SetupLocalWorld();
if (m_sandbox)
{
AssetCache.LoadDefaultTextureSet();
}
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Initialising HTTP server");
this.SetupHttpListener();
LoginServer loginServer = null;
LoginServer adminLoginServer = null;
bool sandBoxWithLoginServer = m_loginserver && m_sandbox;
if (sandBoxWithLoginServer)
{
loginServer = new LoginServer(gridServer, regionData.IPListenAddr, regionData.IPListenPort, regionData.RegionLocX, regionData.RegionLocY, this.user_accounts);
loginServer.Startup();
if (user_accounts)
{
//sandbox mode with loginserver using accounts
this.GridServers.UserServer = loginServer;
adminLoginServer = loginServer;
httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
}
else
{
//sandbox mode with loginserver not using accounts
httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
}
}
AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer);
adminWebFront.LoadMethods(httpServer);
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting HTTP server");
httpServer.Start();
MainServerListener();
m_heartbeatTimer.Enabled = true;
m_heartbeatTimer.Interval = 100;
m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
}
# region Setup methods
protected virtual void SetupLocalGridServers()
{
GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Sandbox mode");
try
{
GridServers.Initialise();
}
catch (Exception e)
{
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface");
Environment.Exit(1);
}
}
protected virtual void SetupRemoteGridServers()
{
if (this.gridLocalAsset)
{
GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
}
else
{
GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
}
GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Grid mode");
try
{
GridServers.Initialise();
}
catch (Exception e)
{
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface");
Environment.Exit(1);
}
}
protected virtual void SetupLocalWorld()
{
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString());
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Initialising world");
m_console.componentname = "Region " + regionData.RegionName;
LocalWorld = new World(this._packetServer.ClientThreads, regionData, regionData.RegionHandle, regionData.RegionName);
LocalWorld.InventoryCache = InventoryCache;
LocalWorld.AssetCache = AssetCache;
this._packetServer.LocalWorld = LocalWorld;
this._packetServer.RegisterClientPacketHandlers();
this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
this.physManager.LoadPlugins();
LocalWorld.m_datastore = this.regionData.DataStore;
LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
LocalWorld.LoadWorldMap();
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting up messaging system");
LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); //should be reading from the config file what physics engine to use
LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D());
LocalWorld.LoadPrimsFromStorage();
}
protected virtual void SetupHttpListener()
{
httpServer = new BaseHttpServer(regionData.IPListenPort);
if (this.GridServers.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",
delegate(XmlRpcRequest request)
{
Hashtable requestData = (Hashtable)request.Params[0];
AgentCircuitData agent_data = new AgentCircuitData();
agent_data.SessionID = new LLUUID((string)requestData["session_id"]);
agent_data.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
agent_data.firstname = (string)requestData["firstname"];
agent_data.lastname = (string)requestData["lastname"];
agent_data.AgentID = new LLUUID((string)requestData["agent_id"]);
agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
{
agent_data.child = true;
}
else
{
agent_data.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["startpos_z"]));
agent_data.child = false;
}
if (((RemoteGridBase)this.GridServers.GridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode))
{
((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode] = agent_data;
}
else
{
((RemoteGridBase)this.GridServers.GridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data);
}
return new XmlRpcResponse();
});
httpServer.AddXmlRPCHandler("agent_crossing",
delegate(XmlRpcRequest request)
{
Hashtable requestData = (Hashtable)request.Params[0];
AgentCircuitData agent_data = new AgentCircuitData();
agent_data.firstname = (string)requestData["firstname"];
agent_data.lastname = (string)requestData["lastname"];
agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
agent_data.startpos = new LLVector3(Single.Parse((string)requestData["pos_x"]), Single.Parse((string)requestData["pos_y"]), Single.Parse((string)requestData["pos_z"]));
if (((RemoteGridBase)this.GridServers.GridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode))
{
((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].firstname = agent_data.firstname;
((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].lastname = agent_data.lastname;
((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].startpos = agent_data.startpos;
}
return new XmlRpcResponse();
});
httpServer.AddRestHandler("GET", "/simstatus/",
delegate(string request, string path, string param)
{
return "OK";
});
}
}
protected virtual void ConnectToRemoteGridServer()
{
if (GridServers.GridServer.RequestConnection(regionData.SimUUID, regionData.IPListenAddr, (uint)regionData.IPListenPort))
{
@ -219,154 +385,9 @@ namespace OpenSim
Environment.Exit(1);
}
}
}
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL,"Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString());
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Initialising world");
m_console.componentname = "Region " + regionData.RegionName;
LocalWorld = new World(this._packetServer.ClientThreads, regionData, regionData.RegionHandle, regionData.RegionName);
LocalWorld.InventoryCache = InventoryCache;
LocalWorld.AssetCache = AssetCache;
this._packetServer.LocalWorld = LocalWorld;
this._packetServer.RegisterClientPacketHandlers();
this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
this.physManager.LoadPlugins();
LocalWorld.m_datastore = this.regionData.DataStore;
LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
LocalWorld.LoadWorldMap();
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting up messaging system");
LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine); //should be reading from the config file what physics engine to use
LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D());
LocalWorld.LoadPrimsFromStorage();
if (m_sandbox)
{
AssetCache.LoadDefaultTextureSet();
}
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Initialising HTTP server");
// HttpServer = new SimCAPSHTTPServer(GridServers.GridServer, Cfg.IPListenPort);
BaseHttpServer httpServer = new BaseHttpServer(regionData.IPListenPort);
if (gridServer.GetName() == "Remote")
{
// should startup the OGS protocol server here
// Are we actually using this?
OGSServer = new OpenGridProtocolServer(this.regionData.IPListenPort - 500); // Changed so we can have more than one OGSServer per machine.
// we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server
httpServer.AddXmlRPCHandler("expect_user",
delegate(XmlRpcRequest request)
{
Hashtable requestData = (Hashtable)request.Params[0];
AgentCircuitData agent_data = new AgentCircuitData();
agent_data.SessionID = new LLUUID((string)requestData["session_id"]);
agent_data.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
agent_data.firstname = (string)requestData["firstname"];
agent_data.lastname = (string)requestData["lastname"];
agent_data.AgentID = new LLUUID((string)requestData["agent_id"]);
agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
{
agent_data.child = true;
}
else
{
agent_data.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["startpos_z"]));
agent_data.child = false;
}
if (((RemoteGridBase)gridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode))
{
((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode] = agent_data;
}
else
{
((RemoteGridBase)gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data);
}
return new XmlRpcResponse();
});
httpServer.AddXmlRPCHandler("agent_crossing",
delegate(XmlRpcRequest request)
{
Hashtable requestData = (Hashtable)request.Params[0];
AgentCircuitData agent_data = new AgentCircuitData();
agent_data.firstname = (string)requestData["firstname"];
agent_data.lastname = (string)requestData["lastname"];
agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
agent_data.startpos = new LLVector3(Single.Parse((string)requestData["pos_x"]), Single.Parse((string)requestData["pos_y"]), Single.Parse((string)requestData["pos_z"]));
if (((RemoteGridBase)gridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode))
{
((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode].firstname = agent_data.firstname;
((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode].lastname = agent_data.lastname;
((RemoteGridBase)gridServer).agentcircuits[(uint)agent_data.circuitcode].startpos = agent_data.startpos;
}
return new XmlRpcResponse();
});
httpServer.AddRestHandler("GET", "/simstatus/",
delegate(string request, string path, string param)
{
return "OK";
});
}
LoginServer loginServer = null;
LoginServer adminLoginServer = null;
bool sandBoxWithLoginServer = m_loginserver && m_sandbox;
if (sandBoxWithLoginServer)
{
loginServer = new LoginServer(gridServer, regionData.IPListenAddr, regionData.IPListenPort,regionData.RegionLocX, regionData.RegionLocY, this.user_accounts);
loginServer.Startup();
if (user_accounts)
{
//sandbox mode with loginserver using accounts
this.GridServers.UserServer = loginServer;
adminLoginServer = loginServer;
httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
}
else
{
//sandbox mode with loginserver not using accounts
httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
}
}
AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer);
adminWebFront.LoadMethods(httpServer);
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting HTTP server");
httpServer.Start();
if (gridServer.GetName() == "Remote")
{
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting up OGS protocol server");
OGSServer.Start();
}
MainServerListener();
m_heartbeatTimer.Enabled = true;
m_heartbeatTimer.Interval = 100;
m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
}
#endregion
private void SetupFromConfigFile(IGenericConfig configData)
{
@ -468,44 +489,7 @@ namespace OpenSim
}
}
private SimConfig LoadConfigDll(string dllName)
{
try
{
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
SimConfig config = null;
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (pluginType.IsPublic)
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("ISimConfig", true);
if (typeInterface != null)
{
ISimConfig plug = (ISimConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
config = plug.GetConfigObject();
break;
}
typeInterface = null;
}
}
}
pluginAssembly = null;
return config;
}
catch (Exception e)
{
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL,e.Message + "\nSorry, a fatal error occurred while trying to load the config DLL");
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL,"Can not continue starting up");
Environment.Exit(1);
return null;
}
}
# region UDP
private void OnReceivedData(IAsyncResult result)
{
ipeSender = new IPEndPoint(IPAddress.Any, 0);
@ -611,6 +595,8 @@ namespace OpenSim
}
}
#endregion
/// <summary>
/// Performs any last-minute sanity checking and shuts down the region server
/// </summary>
@ -637,6 +623,7 @@ namespace OpenSim
LocalWorld.Update();
}
#region Console Commands
/// <summary>
/// Runs commands issued by the server console from the operator
/// </summary>
@ -699,6 +686,7 @@ namespace OpenSim
break;
}
}
#endregion
}

View File

@ -8,8 +8,6 @@ namespace OpenSim
{
public interface OpenSimNetworkHandler
{
//public abstract void StartUp();
// 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

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife.Packets;
namespace OpenSim
{
/*
public class QueItem
{
public QueItem()
{
}
public Packet Packet;
public bool Incoming;
}*/
}

View File

@ -10,19 +10,8 @@ using libsecondlife;
namespace OpenSim
{
public class RegionInfo // could inherit from SimProfileBase
public class RegionInfo : RegionInfoBase
{
public LLUUID SimUUID;
public string RegionName;
public uint RegionLocX;
public uint RegionLocY;
public ulong RegionHandle;
public ushort RegionWaterHeight = 20;
public bool RegionTerraform = true;
public int IPListenPort;
public string IPListenAddr;
//following should be removed and the GenericConfig object passed around,
//so each class (AssetServer, GridServer etc) can access what config data they want
public string AssetURL = "http://127.0.0.1:8003/";

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Web;
using System.IO;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Utilities;
using libsecondlife;
namespace OpenSim
{
public class RegionInfoBase
{
public LLUUID SimUUID;
public string RegionName;
public uint RegionLocX;
public uint RegionLocY;
public ulong RegionHandle;
public ushort RegionWaterHeight = 20;
public bool RegionTerraform = true;
public int IPListenPort;
public string IPListenAddr;
public RegionInfoBase()
{
}
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim
{
public class SimClientBase
{
protected virtual void ProcessInPacket(Packet Pack)
{
}
protected virtual void ProcessOutPacket(Packet Pack)
{
}
public virtual void InPacket(Packet NewPack)
{
}
public virtual void OutPacket(Packet NewPack)
{
}
}
}

View File

@ -0,0 +1,164 @@
using System;
using System.Text;
using System.IO;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Timers;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.world;
using OpenSim.Terrain;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types;
using OpenSim.UserServer;
using OpenSim.Assets;
using OpenSim.CAPS;
using OpenSim.Framework.Console;
using Nwc.XmlRpc;
using OpenSim.Servers;
using OpenSim.GenericConfig;
namespace OpenSim
{
public class UDPServer : OpenSimNetworkHandler
{
private Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
public Socket Server;
private IPEndPoint ServerIncoming;
private byte[] RecvBuffer = new byte[4096];
private byte[] ZeroBuffer = new byte[8192];
private IPEndPoint ipeSender;
private EndPoint epSender;
private AsyncCallback ReceivedData;
private PacketServer _packetServer;
private int listenPort;
private Grid m_gridServers;
private World m_localWorld;
private AssetCache m_assetCache;
private InventoryCache m_inventoryCache;
private RegionInfo m_regionData;
private bool m_sandbox = false;
private bool user_accounts = false;
private ConsoleBase m_console;
public UDPServer(int port, Grid gridServers, World localWorld, AssetCache assetCache, InventoryCache inventoryCache, RegionInfo _regionData, bool sandbox, bool accounts, ConsoleBase console)
{
listenPort = port;
this.m_gridServers = gridServers;
this.m_localWorld = localWorld;
this.m_assetCache = assetCache;
this.m_inventoryCache = inventoryCache;
this.m_regionData = _regionData;
this.m_sandbox = sandbox;
this.user_accounts = accounts;
this.m_console = console;
PacketServer packetServer = new PacketServer(this);
this._packetServer.LocalWorld = m_localWorld;
this._packetServer.RegisterClientPacketHandlers();
}
protected virtual void OnReceivedData(IAsyncResult result)
{
ipeSender = new IPEndPoint(IPAddress.Any, 0);
epSender = (EndPoint)ipeSender;
Packet packet = null;
int numBytes = Server.EndReceiveFrom(result, ref epSender);
int packetEnd = numBytes - 1;
packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
// do we already have a circuit for this endpoint
if (this.clientCircuits.ContainsKey(epSender))
{
//if so then send packet to the packetserver
this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet);
}
else if (packet.Type == PacketType.UseCircuitCode)
{
// new client
this.AddNewClient(packet);
}
else
{ // invalid client
Console.Error.WriteLine("Main.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString());
}
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
}
protected virtual void AddNewClient(Packet packet)
{
UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet;
this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
bool isChildAgent = false;
SimClient newuser = new SimClient(epSender, useCircuit, m_localWorld, _packetServer.ClientThreads, m_assetCache, m_gridServers.GridServer, this, m_inventoryCache, m_sandbox, isChildAgent, this.m_regionData);
if ((this.m_gridServers.UserServer != null) && (user_accounts))
{
newuser.UserServer = this.m_gridServers.UserServer;
}
//OpenSimRoot.Instance.ClientThreads.Add(epSender, newuser);
this._packetServer.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
}
private void ServerListener()
{
m_console.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + listenPort);
ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);
Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
Server.Bind(ServerIncoming);
m_console.WriteLine("Main.cs:MainServerListener() - UDP socket bound, getting ready to listen");
ipeSender = new IPEndPoint(IPAddress.Any, 0);
epSender = (EndPoint)ipeSender;
ReceivedData = new AsyncCallback(this.OnReceivedData);
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
m_console.WriteLine("Main.cs:MainServerListener() - Listening...");
}
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
EndPoint sendto = null;
foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits)
{
if (p.Value == circuitcode)
{
sendto = p.Key;
break;
}
}
if (sendto != null)
{
//we found the endpoint so send the packet to it
this.Server.SendTo(buffer, size, flags, sendto);
}
}
public virtual void RemoveClientCircuit(uint circuitcode)
{
foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits)
{
if (p.Value == circuitcode)
{
this.clientCircuits.Remove(p.Key);
break;
}
}
}
}
}

View File

@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
# Visual C# Express 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Terrain.BasicTerrain", "OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj", "{2270B8FE-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Storage.LocalStorageBerkeleyDB", "OpenSim.Storage\LocalStorageBerkeleyDB\OpenSim.Storage.LocalStorageBerkeleyDB.csproj", "{EE9E5D96-0000-0000-0000-000000000000}"
@ -65,68 +65,6 @@ Global
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
({EE9E5D96-0000-0000-0000-000000000000}).6 = ({8ACA2445-0000-0000-0000-000000000000})
({EE9E5D96-0000-0000-0000-000000000000}).7 = ({A7CD0630-0000-0000-0000-000000000000})
({63A05FE9-0000-0000-0000-000000000000}).2 = ({8BE16150-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).5 = ({8ACA2445-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).6 = ({A7CD0630-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).7 = ({8BE16150-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).8 = ({8BB20F0A-0000-0000-0000-000000000000})
({438A9556-0000-0000-0000-000000000000}).9 = ({632E1BFD-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).5 = ({2270B8FE-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).6 = ({8ACA2445-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).7 = ({A7CD0630-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).8 = ({E88EF749-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).9 = ({8BE16150-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).10 = ({8BB20F0A-0000-0000-0000-000000000000})
({632E1BFD-0000-0000-0000-000000000000}).11 = ({8E81D43C-0000-0000-0000-000000000000})
({8ACA2445-0000-0000-0000-000000000000}).4 = ({8E81D43C-0000-0000-0000-000000000000})
({8BE16150-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({8BE16150-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
({97A82740-0000-0000-0000-000000000000}).2 = ({8ACA2445-0000-0000-0000-000000000000})
({0F3C3AC1-0000-0000-0000-000000000000}).3 = ({62CDF671-0000-0000-0000-000000000000})
({E88EF749-0000-0000-0000-000000000000}).2 = ({8ACA2445-0000-0000-0000-000000000000})
({66591469-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({66591469-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
({66591469-0000-0000-0000-000000000000}).5 = ({8BB20F0A-0000-0000-0000-000000000000})
({66591469-0000-0000-0000-000000000000}).8 = ({8E81D43C-0000-0000-0000-000000000000})
({4F874463-0000-0000-0000-000000000000}).2 = ({8BE16150-0000-0000-0000-000000000000})
({8BB20F0A-0000-0000-0000-000000000000}).2 = ({8ACA2445-0000-0000-0000-000000000000})
({8BB20F0A-0000-0000-0000-000000000000}).3 = ({A7CD0630-0000-0000-0000-000000000000})
({8BB20F0A-0000-0000-0000-000000000000}).5 = ({8E81D43C-0000-0000-0000-000000000000})
({B0027747-0000-0000-0000-000000000000}).5 = ({8ACA2445-0000-0000-0000-000000000000})
({B0027747-0000-0000-0000-000000000000}).6 = ({A7CD0630-0000-0000-0000-000000000000})
({988F0AC4-0000-0000-0000-000000000000}).3 = ({8BE16150-0000-0000-0000-000000000000})
({0A563AC1-0000-0000-0000-000000000000}).3 = ({62CDF671-0000-0000-0000-000000000000})
({7924FD35-0000-0000-0000-000000000000}).1 = ({8ACA2445-0000-0000-0000-000000000000})
({7924FD35-0000-0000-0000-000000000000}).2 = ({8BB20F0A-0000-0000-0000-000000000000})
({7924FD35-0000-0000-0000-000000000000}).3 = ({8E81D43C-0000-0000-0000-000000000000})
({B55C0B5D-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({B55C0B5D-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
({B55C0B5D-0000-0000-0000-000000000000}).5 = ({8E81D43C-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).5 = ({8BB20F0A-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).6 = ({62CDF671-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).7 = ({7924FD35-0000-0000-0000-000000000000})
({21BFC8E2-0000-0000-0000-000000000000}).10 = ({8E81D43C-0000-0000-0000-000000000000})
({E1B79ECF-0000-0000-0000-000000000000}).4 = ({8ACA2445-0000-0000-0000-000000000000})
({E1B79ECF-0000-0000-0000-000000000000}).5 = ({A7CD0630-0000-0000-0000-000000000000})
({6B20B603-0000-0000-0000-000000000000}).5 = ({8ACA2445-0000-0000-0000-000000000000})
({6B20B603-0000-0000-0000-000000000000}).6 = ({A7CD0630-0000-0000-0000-000000000000})
({39BD9497-0000-0000-0000-000000000000}).3 = ({62CDF671-0000-0000-0000-000000000000})
({7E494328-0000-0000-0000-000000000000}).5 = ({8ACA2445-0000-0000-0000-000000000000})
({7E494328-0000-0000-0000-000000000000}).6 = ({A7CD0630-0000-0000-0000-000000000000})
({1E3F341A-0000-0000-0000-000000000000}).4 = ({62CDF671-0000-0000-0000-000000000000})
({546099CD-0000-0000-0000-000000000000}).4 = ({8ACA2445-0000-0000-0000-000000000000})
({546099CD-0000-0000-0000-000000000000}).5 = ({A7CD0630-0000-0000-0000-000000000000})
({0021261B-0000-0000-0000-000000000000}).3 = ({8ACA2445-0000-0000-0000-000000000000})
({0021261B-0000-0000-0000-000000000000}).4 = ({A7CD0630-0000-0000-0000-000000000000})
({0021261B-0000-0000-0000-000000000000}).5 = ({546099CD-0000-0000-0000-000000000000})
({0021261B-0000-0000-0000-000000000000}).6 = ({8BB20F0A-0000-0000-0000-000000000000})
({0021261B-0000-0000-0000-000000000000}).9 = ({8E81D43C-0000-0000-0000-000000000000})
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2270B8FE-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2270B8FE-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU

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>{E141F4EE-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>ServiceManager</AssemblyName>
@ -15,9 +16,11 @@
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Exe</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<AppDesignerFolder>
</AppDesignerFolder>
<RootNamespace>ServiceManager</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,7 +61,8 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
<NoWarn>
</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System">
@ -75,7 +82,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ServiceManager.cs">
<SubType>Code</SubType>
<SubType>Component</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />