aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMW2007-05-16 18:59:51 +0000
committerMW2007-05-16 18:59:51 +0000
commit2a6d69b2b8ab84eec58bf8d0fb786ac6fdfba73f (patch)
tree638f3d03f5ba5184dca03b8cf60211e90976eee3 /OpenSim
parentAdded OpenSimApplication as a base class to OpenSimMain (diff)
downloadopensim-SC_OLD-2a6d69b2b8ab84eec58bf8d0fb786ac6fdfba73f.zip
opensim-SC_OLD-2a6d69b2b8ab84eec58bf8d0fb786ac6fdfba73f.tar.gz
opensim-SC_OLD-2a6d69b2b8ab84eec58bf8d0fb786ac6fdfba73f.tar.bz2
opensim-SC_OLD-2a6d69b2b8ab84eec58bf8d0fb786ac6fdfba73f.tar.xz
Moved the OpenSimMain class into the OpenSim.exe project
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Application.cs3
-rw-r--r--OpenSim/OpenSim.csproj59
-rw-r--r--OpenSim/OpenSim.exe.build4
-rw-r--r--OpenSim/OpenSimMain.cs530
4 files changed, 576 insertions, 20 deletions
diff --git a/OpenSim/Application.cs b/OpenSim/Application.cs
index 240f6c5..3f9c0ec 100644
--- a/OpenSim/Application.cs
+++ b/OpenSim/Application.cs
@@ -7,7 +7,8 @@ using OpenSim.Framework.Console;
7namespace OpenSim 7namespace OpenSim
8{ 8{
9 public class Application 9 public class Application
10 { 10 {
11 //could move our main function into OpenSimMain and kill this class
11 [STAThread] 12 [STAThread]
12 public static void Main(string[] args) 13 public static void Main(string[] args)
13 { 14 {
diff --git a/OpenSim/OpenSim.csproj b/OpenSim/OpenSim.csproj
index f0762b1..6c130fd 100644
--- a/OpenSim/OpenSim.csproj
+++ b/OpenSim/OpenSim.csproj
@@ -1,4 +1,4 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup> 2 <PropertyGroup>
3 <ProjectType>Local</ProjectType> 3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion> 4 <ProductVersion>8.0.50727</ProductVersion>
@@ -6,7 +6,8 @@
6 <ProjectGuid>{438A9556-0000-0000-0000-000000000000}</ProjectGuid> 6 <ProjectGuid>{438A9556-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon> 9 <ApplicationIcon>
10 </ApplicationIcon>
10 <AssemblyKeyContainerName> 11 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName> 12 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim</AssemblyName> 13 <AssemblyName>OpenSim</AssemblyName>
@@ -15,9 +16,11 @@
15 <DefaultTargetSchema>IE50</DefaultTargetSchema> 16 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign> 17 <DelaySign>false</DelaySign>
17 <OutputType>Exe</OutputType> 18 <OutputType>Exe</OutputType>
18 <AppDesignerFolder></AppDesignerFolder> 19 <AppDesignerFolder>
20 </AppDesignerFolder>
19 <RootNamespace>OpenSim</RootNamespace> 21 <RootNamespace>OpenSim</RootNamespace>
20 <StartupObject></StartupObject> 22 <StartupObject>
23 </StartupObject>
21 <FileUpgradeFlags> 24 <FileUpgradeFlags>
22 </FileUpgradeFlags> 25 </FileUpgradeFlags>
23 </PropertyGroup> 26 </PropertyGroup>
@@ -28,7 +31,8 @@
28 <ConfigurationOverrideFile> 31 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile> 32 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants> 33 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile> 34 <DocumentationFile>
35 </DocumentationFile>
32 <DebugSymbols>True</DebugSymbols> 36 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment> 37 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize> 38 <Optimize>False</Optimize>
@@ -37,7 +41,8 @@
37 <RemoveIntegerChecks>False</RemoveIntegerChecks> 41 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors> 42 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel> 43 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn> 44 <NoWarn>
45 </NoWarn>
41 </PropertyGroup> 46 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> 47 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks> 48 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@@ -46,7 +51,8 @@
46 <ConfigurationOverrideFile> 51 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile> 52 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants> 53 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile> 54 <DocumentationFile>
55 </DocumentationFile>
50 <DebugSymbols>False</DebugSymbols> 56 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment> 57 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize> 58 <Optimize>True</Optimize>
@@ -55,26 +61,28 @@
55 <RemoveIntegerChecks>False</RemoveIntegerChecks> 61 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors> 62 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel> 63 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn> 64 <NoWarn>
65 </NoWarn>
59 </PropertyGroup> 66 </PropertyGroup>
60 <ItemGroup> 67 <ItemGroup>
61 <Reference Include="System" > 68 <Reference Include="System">
62 <HintPath>System.dll</HintPath> 69 <HintPath>System.dll</HintPath>
63 <Private>False</Private> 70 <Private>False</Private>
64 </Reference> 71 </Reference>
65 <Reference Include="System.Xml" > 72 <Reference Include="System.Data" />
73 <Reference Include="System.Xml">
66 <HintPath>System.Xml.dll</HintPath> 74 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private> 75 <Private>False</Private>
68 </Reference> 76 </Reference>
69 <Reference Include="libsecondlife.dll" > 77 <Reference Include="libsecondlife.dll">
70 <HintPath>..\bin\libsecondlife.dll</HintPath> 78 <HintPath>..\bin\libsecondlife.dll</HintPath>
71 <Private>False</Private> 79 <Private>False</Private>
72 </Reference> 80 </Reference>
73 <Reference Include="Axiom.MathLib.dll" > 81 <Reference Include="Axiom.MathLib.dll">
74 <HintPath>..\bin\Axiom.MathLib.dll</HintPath> 82 <HintPath>..\bin\Axiom.MathLib.dll</HintPath>
75 <Private>False</Private> 83 <Private>False</Private>
76 </Reference> 84 </Reference>
77 <Reference Include="Db4objects.Db4o.dll" > 85 <Reference Include="Db4objects.Db4o.dll">
78 <HintPath>..\bin\Db4objects.Db4o.dll</HintPath> 86 <HintPath>..\bin\Db4objects.Db4o.dll</HintPath>
79 <Private>False</Private> 87 <Private>False</Private>
80 </Reference> 88 </Reference>
@@ -84,37 +92,50 @@
84 <Name>OpenSim.Framework</Name> 92 <Name>OpenSim.Framework</Name>
85 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project> 93 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
86 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> 94 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
87 <Private>False</Private> 95 <Private>False</Private>
88 </ProjectReference> 96 </ProjectReference>
89 <ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj"> 97 <ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
90 <Name>OpenSim.Framework.Console</Name> 98 <Name>OpenSim.Framework.Console</Name>
91 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project> 99 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
92 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> 100 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
93 <Private>False</Private> 101 <Private>False</Private>
102 </ProjectReference>
103 <ProjectReference Include="..\OpenSim.GenericConfig\Xml\OpenSim.GenericConfig.Xml.csproj">
104 <Project>{E88EF749-0000-0000-0000-000000000000}</Project>
105 <Name>OpenSim.GenericConfig.Xml</Name>
94 </ProjectReference> 106 </ProjectReference>
95 <ProjectReference Include="..\OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj"> 107 <ProjectReference Include="..\OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj">
96 <Name>OpenSim.Physics.Manager</Name> 108 <Name>OpenSim.Physics.Manager</Name>
97 <Project>{8BE16150-0000-0000-0000-000000000000}</Project> 109 <Project>{8BE16150-0000-0000-0000-000000000000}</Project>
98 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> 110 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
99 <Private>False</Private> 111 <Private>False</Private>
100 </ProjectReference> 112 </ProjectReference>
101 <ProjectReference Include="..\OpenSim.Servers\OpenSim.Servers.csproj"> 113 <ProjectReference Include="..\OpenSim.Servers\OpenSim.Servers.csproj">
102 <Name>OpenSim.Servers</Name> 114 <Name>OpenSim.Servers</Name>
103 <Project>{8BB20F0A-0000-0000-0000-000000000000}</Project> 115 <Project>{8BB20F0A-0000-0000-0000-000000000000}</Project>
104 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> 116 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
105 <Private>False</Private> 117 <Private>False</Private>
106 </ProjectReference> 118 </ProjectReference>
107 <ProjectReference Include="..\OpenSim.RegionServer\OpenSim.RegionServer.csproj"> 119 <ProjectReference Include="..\OpenSim.RegionServer\OpenSim.RegionServer.csproj">
108 <Name>OpenSim.RegionServer</Name> 120 <Name>OpenSim.RegionServer</Name>
109 <Project>{632E1BFD-0000-0000-0000-000000000000}</Project> 121 <Project>{632E1BFD-0000-0000-0000-000000000000}</Project>
110 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> 122 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
111 <Private>False</Private> 123 <Private>False</Private>
124 </ProjectReference>
125 <ProjectReference Include="..\OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj">
126 <Project>{2270B8FE-0000-0000-0000-000000000000}</Project>
127 <Name>OpenSim.Terrain.BasicTerrain</Name>
128 </ProjectReference>
129 <ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj">
130 <Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
131 <Name>XMLRPC</Name>
112 </ProjectReference> 132 </ProjectReference>
113 </ItemGroup> 133 </ItemGroup>
114 <ItemGroup> 134 <ItemGroup>
115 <Compile Include="Application.cs"> 135 <Compile Include="Application.cs">
116 <SubType>Code</SubType> 136 <SubType>Code</SubType>
117 </Compile> 137 </Compile>
138 <Compile Include="OpenSimMain.cs" />
118 </ItemGroup> 139 </ItemGroup>
119 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> 140 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
120 <PropertyGroup> 141 <PropertyGroup>
@@ -123,4 +144,4 @@
123 <PostBuildEvent> 144 <PostBuildEvent>
124 </PostBuildEvent> 145 </PostBuildEvent>
125 </PropertyGroup> 146 </PropertyGroup>
126</Project> 147</Project> \ No newline at end of file
diff --git a/OpenSim/OpenSim.exe.build b/OpenSim/OpenSim.exe.build
index 02445df..19d0b28 100644
--- a/OpenSim/OpenSim.exe.build
+++ b/OpenSim/OpenSim.exe.build
@@ -12,6 +12,7 @@
12 </resources> 12 </resources>
13 <sources failonempty="true"> 13 <sources failonempty="true">
14 <include name="Application.cs" /> 14 <include name="Application.cs" />
15 <include name="OpenSimMain.cs" />
15 </sources> 16 </sources>
16 <references basedir="${project::get-base-directory()}"> 17 <references basedir="${project::get-base-directory()}">
17 <lib> 18 <lib>
@@ -23,11 +24,14 @@
23 <include name="../bin/libsecondlife.dll" /> 24 <include name="../bin/libsecondlife.dll" />
24 <include name="../bin/Axiom.MathLib.dll" /> 25 <include name="../bin/Axiom.MathLib.dll" />
25 <include name="../bin/Db4objects.Db4o.dll" /> 26 <include name="../bin/Db4objects.Db4o.dll" />
27 <include name="../bin/OpenSim.Terrain.BasicTerrain.dll" />
26 <include name="../bin/OpenSim.Framework.dll" /> 28 <include name="../bin/OpenSim.Framework.dll" />
27 <include name="../bin/OpenSim.Framework.Console.dll" /> 29 <include name="../bin/OpenSim.Framework.Console.dll" />
28 <include name="../bin/OpenSim.Physics.Manager.dll" /> 30 <include name="../bin/OpenSim.Physics.Manager.dll" />
29 <include name="../bin/OpenSim.Servers.dll" /> 31 <include name="../bin/OpenSim.Servers.dll" />
30 <include name="../bin/OpenSim.RegionServer.dll" /> 32 <include name="../bin/OpenSim.RegionServer.dll" />
33 <include name="../bin/OpenSim.GenericConfig.Xml.dll" />
34 <include name="../bin/XMLRPC.dll" />
31 </references> 35 </references>
32 </csc> 36 </csc>
33 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../bin/" /> 37 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../bin/" />
diff --git a/OpenSim/OpenSimMain.cs b/OpenSim/OpenSimMain.cs
new file mode 100644
index 0000000..b7c8bef
--- /dev/null
+++ b/OpenSim/OpenSimMain.cs
@@ -0,0 +1,530 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4* All rights reserved.
5*
6* Redistribution and use in source and binary forms, with or without
7* modification, are permitted provided that the following conditions are met:
8* * Redistributions of source code must retain the above copyright
9* notice, this list of conditions and the following disclaimer.
10* * Redistributions in binary form must reproduce the above copyright
11* notice, this list of conditions and the following disclaimer in the
12* documentation and/or other materials provided with the distribution.
13* * Neither the name of the <organization> nor the
14* names of its contributors may be used to endorse or promote products
15* derived from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
18* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
21* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29using System;
30using System.Text;
31using System.IO;
32using System.Threading;
33using System.Net;
34using System.Net.Sockets;
35using System.Timers;
36using System.Reflection;
37using System.Collections;
38using System.Collections.Generic;
39using libsecondlife;
40using libsecondlife.Packets;
41using OpenSim.world;
42using OpenSim.Terrain;
43using OpenSim.Framework.Interfaces;
44using OpenSim.Framework.Types;
45using OpenSim.UserServer;
46using OpenSim.Assets;
47using OpenSim.CAPS;
48using OpenSim.Framework.Console;
49using OpenSim.Physics.Manager;
50using Nwc.XmlRpc;
51using OpenSim.Servers;
52using OpenSim.GenericConfig;
53
54namespace OpenSim
55{
56
57 public class OpenSimMain : OpenSimApplicationBase, conscmd_callback
58 {
59
60 public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
61 {
62 this.configFileSetup = useConfigFile;
63 m_sandbox = sandBoxMode;
64 m_loginserver = startLoginServer;
65 m_physicsEngine = physicsEngine;
66 m_config = configFile;
67
68 m_console = new ConsoleBase("region-console-" + Guid.NewGuid().ToString() + ".log", "Region", this, silent);
69 OpenSim.Framework.Console.MainConsole.Instance = m_console;
70 }
71
72 /// <summary>
73 /// Performs initialisation of the world, such as loading configuration from disk.
74 /// </summary>
75 public override void StartUp()
76 {
77 this.regionData = new RegionInfo();
78 try
79 {
80 this.localConfig = new XmlConfig(m_config);
81 this.localConfig.LoadData();
82 }
83 catch (Exception e)
84 {
85 Console.WriteLine(e.Message);
86 }
87 if (this.configFileSetup)
88 {
89 this.SetupFromConfigFile(this.localConfig);
90 }
91 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Loading configuration");
92 this.regionData.InitConfig(this.m_sandbox, this.localConfig);
93 this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change
94
95 GridServers = new Grid();
96 if (m_sandbox)
97 {
98 this.SetupLocalGridServers();
99 //Authenticate Session Handler
100 AuthenticateSessionsLocal authen = new AuthenticateSessionsLocal();
101 this.AuthenticateSessionsHandler = authen;
102 }
103 else
104 {
105 this.SetupRemoteGridServers();
106 //Authenticate Session Handler
107 AuthenticateSessionsRemote authen = new AuthenticateSessionsRemote();
108 this.AuthenticateSessionsHandler = authen;
109 }
110
111 startuptime = DateTime.Now;
112
113 try
114 {
115 AssetCache = new AssetCache(GridServers.AssetServer);
116 InventoryCache = new InventoryCache();
117 }
118 catch (Exception e)
119 {
120 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup local cache");
121 Environment.Exit(1);
122 }
123
124 m_udpServer = new UDPServer(this.regionData.IPListenPort, this.GridServers, this.AssetCache, this.InventoryCache, this.regionData, this.m_sandbox, this.user_accounts, this.m_console, this.AuthenticateSessionsHandler);
125
126 //should be passing a IGenericConfig object to these so they can read the config data they want from it
127 GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey);
128 IGridServer gridServer = GridServers.GridServer;
129 gridServer.SetServerInfo(regionData.GridURL, regionData.GridSendKey, regionData.GridRecvKey);
130
131 if (!m_sandbox)
132 {
133 this.ConnectToRemoteGridServer();
134 }
135
136 this.SetupLocalWorld();
137
138 if (m_sandbox)
139 {
140 AssetCache.LoadDefaultTextureSet();
141 }
142
143 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Initialising HTTP server");
144
145 this.SetupHttpListener();
146
147 LoginServer loginServer = null;
148 LoginServer adminLoginServer = null;
149
150 bool sandBoxWithLoginServer = m_loginserver && m_sandbox;
151 if (sandBoxWithLoginServer)
152 {
153 loginServer = new LoginServer(regionData.IPListenAddr, regionData.IPListenPort, regionData.RegionLocX, regionData.RegionLocY, this.user_accounts);
154 loginServer.Startup();
155 loginServer.SetSessionHandler(((AuthenticateSessionsLocal)this.AuthenticateSessionsHandler).AddNewSession);
156
157 if (user_accounts)
158 {
159 //sandbox mode with loginserver using accounts
160 this.GridServers.UserServer = loginServer;
161 adminLoginServer = loginServer;
162
163 httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.LocalUserManager.XmlRpcLoginMethod);
164 }
165 else
166 {
167 //sandbox mode with loginserver not using accounts
168 httpServer.AddXmlRPCHandler("login_to_simulator", loginServer.XmlRpcLoginMethod);
169 }
170 }
171
172 AdminWebFront adminWebFront = new AdminWebFront("Admin", LocalWorld, InventoryCache, adminLoginServer);
173 adminWebFront.LoadMethods(httpServer);
174
175 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting HTTP server");
176 httpServer.Start();
177
178 //MainServerListener();
179 this.m_udpServer.ServerListener();
180
181 m_heartbeatTimer.Enabled = true;
182 m_heartbeatTimer.Interval = 100;
183 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
184 }
185
186 # region Setup methods
187 protected virtual void SetupLocalGridServers()
188 {
189 GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
190 GridServers.GridDll = "OpenSim.GridInterfaces.Local.dll";
191
192 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Sandbox mode");
193
194 try
195 {
196 GridServers.Initialise();
197 }
198 catch (Exception e)
199 {
200 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface");
201 Environment.Exit(1);
202 }
203 }
204
205 protected virtual void SetupRemoteGridServers()
206 {
207 if (this.gridLocalAsset)
208 {
209 GridServers.AssetDll = "OpenSim.GridInterfaces.Local.dll";
210 }
211 else
212 {
213 GridServers.AssetDll = "OpenSim.GridInterfaces.Remote.dll";
214 }
215 GridServers.GridDll = "OpenSim.GridInterfaces.Remote.dll";
216
217 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Starting in Grid mode");
218
219 try
220 {
221 GridServers.Initialise();
222 }
223 catch (Exception e)
224 {
225 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, e.Message + "\nSorry, could not setup the grid interface");
226 Environment.Exit(1);
227 }
228 }
229
230 protected virtual void SetupLocalWorld()
231 {
232 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Main.cs:Startup() - We are " + regionData.RegionName + " at " + regionData.RegionLocX.ToString() + "," + regionData.RegionLocY.ToString());
233 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Initialising world");
234 m_console.componentname = "Region " + regionData.RegionName;
235
236 m_localWorld = new World(this.m_udpServer.PacketServer.ClientThreads, regionData, regionData.RegionHandle, regionData.RegionName);
237 LocalWorld.InventoryCache = InventoryCache;
238 LocalWorld.AssetCache = AssetCache;
239
240 this.m_udpServer.LocalWorld = LocalWorld;
241 this.m_udpServer.PacketServer.RegisterClientPacketHandlers();
242
243 this.physManager = new OpenSim.Physics.Manager.PhysicsManager();
244 this.physManager.LoadPlugins();
245
246 LocalWorld.m_datastore = this.regionData.DataStore;
247
248 LocalWorld.LoadStorageDLL("OpenSim.Storage.LocalStorageDb4o.dll"); //all these dll names shouldn't be hard coded.
249 LocalWorld.LoadWorldMap();
250
251 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Starting up messaging system");
252 LocalWorld.PhysScene = this.physManager.GetPhysicsScene(this.m_physicsEngine);
253 LocalWorld.PhysScene.SetTerrain(LocalWorld.Terrain.getHeights1D());
254 LocalWorld.LoadPrimsFromStorage();
255 }
256
257 protected virtual void SetupHttpListener()
258 {
259 httpServer = new BaseHttpServer(regionData.IPListenPort);
260
261 if (this.GridServers.GridServer.GetName() == "Remote")
262 {
263
264 // we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server
265 httpServer.AddXmlRPCHandler("expect_user", ((AuthenticateSessionsRemote)this.AuthenticateSessionsHandler).ExpectUser);
266
267 httpServer.AddXmlRPCHandler("agent_crossing",
268 delegate(XmlRpcRequest request)
269 {
270 Hashtable requestData = (Hashtable)request.Params[0];
271 AgentCircuitData agent_data = new AgentCircuitData();
272 agent_data.firstname = (string)requestData["firstname"];
273 agent_data.lastname = (string)requestData["lastname"];
274 agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
275 agent_data.startpos = new LLVector3(Single.Parse((string)requestData["pos_x"]), Single.Parse((string)requestData["pos_y"]), Single.Parse((string)requestData["pos_z"]));
276
277 if (((RemoteGridBase)this.GridServers.GridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode))
278 {
279 ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].firstname = agent_data.firstname;
280 ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].lastname = agent_data.lastname;
281 ((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode].startpos = agent_data.startpos;
282 }
283
284 return new XmlRpcResponse();
285 });
286
287 httpServer.AddRestHandler("GET", "/simstatus/",
288 delegate(string request, string path, string param)
289 {
290 return "OK";
291 });
292 }
293 }
294
295 protected virtual void ConnectToRemoteGridServer()
296 {
297 if (GridServers.GridServer.RequestConnection(regionData.SimUUID, regionData.IPListenAddr, (uint)regionData.IPListenPort))
298 {
299 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Success: Got a grid connection OK!");
300 }
301 else
302 {
303 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, "Main.cs:Startup() - FAILED: Unable to get connection to grid. Shutting down.");
304 Shutdown();
305 }
306
307 GridServers.AssetServer.SetServerInfo((string)((RemoteGridBase)GridServers.GridServer).GridData["asset_url"], (string)((RemoteGridBase)GridServers.GridServer).GridData["asset_sendkey"]);
308
309 // If we are being told to load a file, load it.
310 string dataUri = (string)((RemoteGridBase)GridServers.GridServer).GridData["data_uri"];
311
312 if (!String.IsNullOrEmpty(dataUri))
313 {
314 this.LocalWorld.m_datastore = dataUri;
315 }
316
317 if (((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString() != "")
318 {
319 // The grid server has told us who we are
320 // We must obey the grid server.
321 try
322 {
323 regionData.RegionLocX = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locx"].ToString());
324 regionData.RegionLocY = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locy"].ToString());
325 regionData.RegionName = ((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString();
326 }
327 catch (Exception e)
328 {
329 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.CRITICAL, e.Message + "\nBAD ERROR! THIS SHOULD NOT HAPPEN! Bad GridData from the grid interface!!!! ZOMG!!!");
330 Environment.Exit(1);
331 }
332 }
333 }
334
335 #endregion
336
337 private void SetupFromConfigFile(IGenericConfig configData)
338 {
339 try
340 {
341 // SandBoxMode
342 string attri = "";
343 attri = configData.GetAttribute("SandBox");
344 if ((attri == "") || ((attri != "false") && (attri != "true")))
345 {
346 this.m_sandbox = false;
347 configData.SetAttribute("SandBox", "false");
348 }
349 else
350 {
351 this.m_sandbox = Convert.ToBoolean(attri);
352 }
353
354 // LoginServer
355 attri = "";
356 attri = configData.GetAttribute("LoginServer");
357 if ((attri == "") || ((attri != "false") && (attri != "true")))
358 {
359 this.m_loginserver = false;
360 configData.SetAttribute("LoginServer", "false");
361 }
362 else
363 {
364 this.m_loginserver = Convert.ToBoolean(attri);
365 }
366
367 // Sandbox User accounts
368 attri = "";
369 attri = configData.GetAttribute("UserAccount");
370 if ((attri == "") || ((attri != "false") && (attri != "true")))
371 {
372 this.user_accounts = false;
373 configData.SetAttribute("UserAccounts", "false");
374 }
375 else if (attri == "true")
376 {
377 this.user_accounts = Convert.ToBoolean(attri);
378 }
379
380 // Grid mode hack to use local asset server
381 attri = "";
382 attri = configData.GetAttribute("LocalAssets");
383 if ((attri == "") || ((attri != "false") && (attri != "true")))
384 {
385 this.gridLocalAsset = false;
386 configData.SetAttribute("LocalAssets", "false");
387 }
388 else if (attri == "true")
389 {
390 this.gridLocalAsset = Convert.ToBoolean(attri);
391 }
392
393
394 attri = "";
395 attri = configData.GetAttribute("PhysicsEngine");
396 switch (attri)
397 {
398 default:
399 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating");
400 Environment.Exit(1);
401 break;
402
403 case "":
404 this.m_physicsEngine = "basicphysics";
405 configData.SetAttribute("PhysicsEngine", "basicphysics");
406 OpenSim.world.Avatar.PhysicsEngineFlying = false;
407 break;
408
409 case "basicphysics":
410 this.m_physicsEngine = "basicphysics";
411 configData.SetAttribute("PhysicsEngine", "basicphysics");
412 OpenSim.world.Avatar.PhysicsEngineFlying = false;
413 break;
414
415 case "RealPhysX":
416 this.m_physicsEngine = "RealPhysX";
417 OpenSim.world.Avatar.PhysicsEngineFlying = true;
418 break;
419
420 case "OpenDynamicsEngine":
421 this.m_physicsEngine = "OpenDynamicsEngine";
422 OpenSim.world.Avatar.PhysicsEngineFlying = true;
423 break;
424 }
425
426 configData.Commit();
427 }
428 catch (Exception e)
429 {
430 Console.WriteLine(e.Message);
431 Console.WriteLine("\nSorry, a fatal error occurred while trying to initialise the configuration data");
432 Console.WriteLine("Can not continue starting up");
433 Environment.Exit(1);
434 }
435 }
436
437 /// <summary>
438 /// Performs any last-minute sanity checking and shuts down the region server
439 /// </summary>
440 public virtual void Shutdown()
441 {
442 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing all threads");
443 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing listener thread");
444 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Killing clients");
445 // IMPLEMENT THIS
446 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Shutdown() - Closing console and terminating");
447 LocalWorld.Close();
448 GridServers.Close();
449 m_console.Close();
450 Environment.Exit(0);
451 }
452
453 /// <summary>
454 /// Performs per-frame updates regularly
455 /// </summary>
456 /// <param name="sender"></param>
457 /// <param name="e"></param>
458 void Heartbeat(object sender, System.EventArgs e)
459 {
460 LocalWorld.Update();
461 }
462
463 #region Console Commands
464 /// <summary>
465 /// Runs commands issued by the server console from the operator
466 /// </summary>
467 /// <param name="command">The first argument of the parameter (the command)</param>
468 /// <param name="cmdparams">Additional arguments passed to the command</param>
469 public void RunCmd(string command, string[] cmdparams)
470 {
471 switch (command)
472 {
473 case "help":
474 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "show users - show info about connected users");
475 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "shutdown - disconnect all clients and shutdown");
476 break;
477
478 case "show":
479 Show(cmdparams[0]);
480 break;
481
482 case "terrain":
483 string result = "";
484 if (!LocalWorld.Terrain.RunTerrainCmd(cmdparams, ref result))
485 {
486 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, result);
487 }
488 break;
489
490 case "shutdown":
491 Shutdown();
492 break;
493
494 default:
495 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "Unknown command");
496 break;
497 }
498 }
499
500 /// <summary>
501 /// Outputs to the console information about the region
502 /// </summary>
503 /// <param name="ShowWhat">What information to display (valid arguments are "uptime", "users")</param>
504 public void Show(string ShowWhat)
505 {
506 switch (ShowWhat)
507 {
508 case "uptime":
509 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "OpenSim has been running since " + startuptime.ToString());
510 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "That is " + (DateTime.Now - startuptime).ToString());
511 break;
512 case "users":
513 OpenSim.world.Avatar TempAv;
514 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP"));
515 foreach (libsecondlife.LLUUID UUID in LocalWorld.Entities.Keys)
516 {
517 if (LocalWorld.Entities[UUID].ToString() == "OpenSim.world.Avatar")
518 {
519 TempAv = (OpenSim.world.Avatar)LocalWorld.Entities[UUID];
520 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}", TempAv.firstname, TempAv.lastname, UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString()));
521 }
522 }
523 break;
524 }
525 }
526 #endregion
527 }
528
529
530} \ No newline at end of file