OpenSimMain.cs 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Diagnostics;
  30. using System.IO;
  31. using System.Text;
  32. using System.Threading;
  33. using System.Timers;
  34. using Nini.Config;
  35. using OpenSim.Framework;
  36. using OpenSim.Framework.Communications.Cache;
  37. using OpenSim.Framework.Console;
  38. using OpenSim.Framework.Servers;
  39. using OpenSim.Framework.Statistics;
  40. using OpenSim.Region.ClientStack;
  41. using OpenSim.Region.Communications.Local;
  42. using OpenSim.Region.Communications.OGS1;
  43. using OpenSim.Region.Environment;
  44. using OpenSim.Region.Environment.Interfaces;
  45. using OpenSim.Region.Environment.Scenes;
  46. using OpenSim.Region.Physics.Manager;
  47. using Timer=System.Timers.Timer;
  48. using System.Net;
  49. using Nwc.XmlRpc;
  50. using System.Collections;
  51. using System.Reflection;
  52. using libsecondlife;
  53. using Mono.Addins;
  54. using Mono.Addins.Description;
  55. namespace OpenSim
  56. {
  57. public delegate void ConsoleCommand(string[] comParams);
  58. public class OpenSimMain : RegionApplicationBase, conscmd_callback
  59. {
  60. private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  61. private string proxyUrl;
  62. private int proxyOffset = 0;
  63. private const string DEFAULT_PRIM_BACKUP_FILENAME = "prim-backup.xml";
  64. public string m_physicsEngine;
  65. public string m_meshEngineName;
  66. public string m_scriptEngine;
  67. public bool m_sandbox;
  68. public bool user_accounts;
  69. public bool m_gridLocalAsset;
  70. public bool m_see_into_region_from_neighbor;
  71. protected LocalLoginService m_loginService;
  72. protected string m_storageDll;
  73. protected string m_startupCommandsFile;
  74. protected string m_shutdownCommandsFile;
  75. protected List<UDPServer> m_udpServers = new List<UDPServer>();
  76. protected List<RegionInfo> m_regionData = new List<RegionInfo>();
  77. private bool m_physicalPrim;
  78. private bool m_permissions = false;
  79. private bool m_standaloneAuthenticate = false;
  80. private string m_standaloneWelcomeMessage = null;
  81. private string m_standaloneInventoryPlugin;
  82. private string m_standaloneAssetPlugin;
  83. private string m_standaloneUserPlugin;
  84. private string m_assetStorage = "local";
  85. private string m_timedScript = "disabled";
  86. private Timer m_scriptTimer;
  87. public ConsoleCommand CreateAccount = null;
  88. private bool m_dumpAssetsToFile;
  89. private List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>();
  90. private IniConfigSource m_config;
  91. public IniConfigSource ConfigSource
  92. {
  93. get { return m_config; }
  94. set { m_config = value; }
  95. }
  96. public BaseHttpServer HttpServer
  97. {
  98. get { return m_httpServer; }
  99. }
  100. public List<UDPServer> UdpServers
  101. {
  102. get { return m_udpServers; }
  103. }
  104. public List<RegionInfo> RegionData
  105. {
  106. get { return m_regionData; }
  107. }
  108. private ModuleLoader m_moduleLoader;
  109. public ModuleLoader ModuleLoader
  110. {
  111. get { return m_moduleLoader; }
  112. set { m_moduleLoader = value; }
  113. }
  114. public OpenSimMain(IConfigSource configSource)
  115. : base()
  116. {
  117. IConfig startupConfig = configSource.Configs["Startup"];
  118. // The Mono addin manager (in Mono.Addins.dll version 0.2.0.0) occasionally seems to corrupt its addin cache
  119. // Hence, as a temporary solution we'll remove it before each startup
  120. if (Directory.Exists("addin-db-000"))
  121. {
  122. Directory.Delete("addin-db-000", true);
  123. }
  124. AddinManager.Initialize(".");
  125. AddinManager.Registry.Update(null);
  126. Application.iniFilePath = startupConfig.GetString("inifile", "OpenSim.ini");
  127. m_config = new IniConfigSource();
  128. //check for .INI file (either default or name passed in command line)
  129. if (File.Exists(Application.iniFilePath))
  130. {
  131. m_config.Merge(new IniConfigSource(Application.iniFilePath));
  132. m_config.Merge(configSource);
  133. }
  134. else
  135. {
  136. Application.iniFilePath = Path.Combine(Util.configDir(), Application.iniFilePath);
  137. if (File.Exists(Application.iniFilePath))
  138. {
  139. m_config.Merge(new IniConfigSource(Application.iniFilePath));
  140. m_config.Merge(configSource);
  141. }
  142. else
  143. {
  144. // no default config files, so set default values, and save it
  145. m_config.Merge(DefaultConfig());
  146. m_config.Merge(configSource);
  147. m_config.Save(Application.iniFilePath);
  148. }
  149. }
  150. ReadConfigSettings();
  151. }
  152. public static IConfigSource DefaultConfig()
  153. {
  154. IConfigSource DefaultConfig = new IniConfigSource();
  155. if (DefaultConfig.Configs["Startup"] == null)
  156. DefaultConfig.AddConfig("Startup");
  157. IConfig config = DefaultConfig.Configs["Startup"];
  158. if (config != null)
  159. {
  160. config.Set("gridmode", false);
  161. config.Set("physics", "basicphysics");
  162. config.Set("physical_prim", true);
  163. config.Set("see_into_this_sim_from_neighbor", true);
  164. config.Set("serverside_object_permissions", false);
  165. config.Set("storage_plugin", "OpenSim.Framework.Data.SQLite.dll");
  166. config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3");
  167. config.Set("storage_prim_inventories", true);
  168. config.Set("startup_console_commands_file", String.Empty);
  169. config.Set("shutdown_console_commands_file", String.Empty);
  170. config.Set("script_engine", "OpenSim.Region.ScriptEngine.DotNetEngine.dll");
  171. config.Set("asset_database", "sqlite");
  172. }
  173. if (DefaultConfig.Configs["StandAlone"] == null)
  174. DefaultConfig.AddConfig("StandAlone");
  175. config = DefaultConfig.Configs["StandAlone"];
  176. if (config != null)
  177. {
  178. config.Set("accounts_authenticate", false);
  179. config.Set("welcome_message", "Welcome to OpenSim");
  180. config.Set("inventory_plugin", "OpenSim.Framework.Data.SQLite.dll");
  181. config.Set("userDatabase_plugin", "OpenSim.Framework.Data.SQLite.dll");
  182. config.Set("asset_plugin", "OpenSim.Framework.Data.SQLite.dll");
  183. config.Set("dump_assets_to_file", false);
  184. }
  185. if (DefaultConfig.Configs["Network"] == null)
  186. DefaultConfig.AddConfig("Network");
  187. config = DefaultConfig.Configs["Network"];
  188. if (config != null)
  189. {
  190. config.Set("default_location_x", 1000);
  191. config.Set("default_location_y", 1000);
  192. config.Set("http_listener_port", NetworkServersInfo.DefaultHttpListenerPort);
  193. config.Set("remoting_listener_port", NetworkServersInfo.RemotingListenerPort);
  194. config.Set("grid_server_url", "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString());
  195. config.Set("grid_send_key", "null");
  196. config.Set("grid_recv_key", "null");
  197. config.Set("user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString());
  198. config.Set("user_send_key", "null");
  199. config.Set("user_recv_key", "null");
  200. config.Set("asset_server_url", "http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString());
  201. config.Set("inventory_server_url", "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort.ToString());
  202. }
  203. if (DefaultConfig.Configs["RemoteAdmin"] == null)
  204. DefaultConfig.AddConfig("RemoteAdmin");
  205. config = DefaultConfig.Configs["RemoteAdmin"];
  206. if (config != null)
  207. {
  208. config.Set("enabled", "false");
  209. }
  210. return DefaultConfig;
  211. }
  212. protected void ReadConfigSettings()
  213. {
  214. m_networkServersInfo = new NetworkServersInfo();
  215. IConfig startupConfig = m_config.Configs["Startup"];
  216. if (startupConfig != null)
  217. {
  218. m_sandbox = !startupConfig.GetBoolean("gridmode", false);
  219. m_physicsEngine = startupConfig.GetString("physics", "basicphysics");
  220. m_meshEngineName = startupConfig.GetString("meshing", "ZeroMesher");
  221. m_physicalPrim = startupConfig.GetBoolean("physical_prim", true);
  222. m_see_into_region_from_neighbor = startupConfig.GetBoolean("see_into_this_sim_from_neighbor", true);
  223. m_permissions = startupConfig.GetBoolean("serverside_object_permissions", false);
  224. m_storageDll = startupConfig.GetString("storage_plugin", "OpenSim.Framework.Data.SQLite.dll");
  225. if (m_storageDll == "OpenSim.DataStore.MonoSqlite.dll")
  226. {
  227. m_storageDll = "OpenSim.Framework.Data.SQLite.dll";
  228. Console.WriteLine("WARNING: OpenSim.DataStore.MonoSqlite.dll is deprecated. Set storage_plugin to OpenSim.Framework.Data.SQLite.dll.");
  229. Thread.Sleep(3000);
  230. }
  231. m_storageConnectionString
  232. = startupConfig.GetString("storage_connection_string", "URI=file:OpenSim.db,version=3");
  233. m_storagePersistPrimInventories
  234. = startupConfig.GetBoolean("storage_prim_inventories", true);
  235. m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", String.Empty);
  236. m_shutdownCommandsFile = startupConfig.GetString("shutdown_console_commands_file", String.Empty);
  237. m_scriptEngine = startupConfig.GetString("script_engine", "OpenSim.Region.ScriptEngine.DotNetEngine.dll");
  238. m_assetStorage = startupConfig.GetString("asset_database", "local");
  239. m_timedScript = startupConfig.GetString("timer_Script", "disabled");
  240. }
  241. IConfig standaloneConfig = m_config.Configs["StandAlone"];
  242. if (standaloneConfig != null)
  243. {
  244. m_standaloneAuthenticate = standaloneConfig.GetBoolean("accounts_authenticate", false);
  245. m_standaloneWelcomeMessage = standaloneConfig.GetString("welcome_message", "Welcome to OpenSim");
  246. m_standaloneInventoryPlugin =
  247. standaloneConfig.GetString("inventory_plugin", "OpenSim.Framework.Data.SQLite.dll");
  248. m_standaloneUserPlugin =
  249. standaloneConfig.GetString("userDatabase_plugin", "OpenSim.Framework.Data.SQLite.dll");
  250. m_standaloneAssetPlugin =
  251. standaloneConfig.GetString("asset_plugin", "OpenSim.Framework.Data.SQLite.dll");
  252. m_dumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file", false);
  253. }
  254. //if (!m_sandbox)
  255. //m_SendChildAgentTaskData = false;
  256. m_networkServersInfo.loadFromConfiguration(m_config);
  257. }
  258. /// <summary>
  259. /// Performs initialisation of the scene, such as loading configuration from disk.
  260. /// </summary>
  261. public override void StartUp()
  262. {
  263. //
  264. // Called from app startup (OpenSim.Application)
  265. //
  266. m_log.Info("====================================================================");
  267. m_log.Info("========================= STARTING OPENSIM =========================");
  268. m_log.Info("====================================================================");
  269. m_log.InfoFormat("[OPENSIM MAIN]: Running in {0} mode", (m_sandbox ? "sandbox" : "grid"));
  270. m_console = CreateConsole();
  271. MainConsole.Instance = m_console;
  272. StatsManager.StartCollectingSimExtraStats();
  273. // Do baseclass startup sequence: OpenSim.Region.ClientStack.RegionApplicationBase.StartUp
  274. // TerrainManager, StorageManager, HTTP Server
  275. // This base will call abstract Initialize
  276. base.StartUp();
  277. // StandAlone mode? m_sandbox is determined by !startupConfig.GetBoolean("gridmode", false)
  278. if (m_sandbox)
  279. {
  280. LocalInventoryService inventoryService = new LocalInventoryService();
  281. inventoryService.AddPlugin(m_standaloneInventoryPlugin);
  282. LocalUserServices userService =
  283. new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX,
  284. m_networkServersInfo.DefaultHomeLocY, inventoryService);
  285. userService.AddPlugin(m_standaloneUserPlugin);
  286. LocalBackEndServices backendService = new LocalBackEndServices();
  287. CommunicationsLocal localComms =
  288. new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, userService,
  289. inventoryService, backendService, backendService, m_dumpAssetsToFile);
  290. m_commsManager = localComms;
  291. m_loginService =
  292. new LocalLoginService(userService, m_standaloneWelcomeMessage, localComms, m_networkServersInfo,
  293. m_standaloneAuthenticate);
  294. m_loginService.OnLoginToRegion += backendService.AddNewSession;
  295. // set up XMLRPC handler for client's initial login request message
  296. m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod);
  297. // provides the web form login
  298. m_httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin);
  299. // Provides the LLSD login
  300. m_httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod);
  301. CreateAccount = localComms.doCreate;
  302. }
  303. else
  304. {
  305. // We are in grid mode
  306. m_commsManager = new CommunicationsOGS1(m_networkServersInfo, m_httpServer, m_assetCache);
  307. m_httpServer.AddStreamHandler(new SimStatusHandler());
  308. }
  309. proxyUrl = ConfigSource.Configs["Network"].GetString("proxy_url", "");
  310. proxyOffset = Int32.Parse(ConfigSource.Configs["Network"].GetString("proxy_offset", "0"));
  311. // Create a ModuleLoader instance
  312. m_moduleLoader = new ModuleLoader(m_config);
  313. ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/Startup");
  314. foreach (TypeExtensionNode node in nodes)
  315. {
  316. m_log.InfoFormat("[PLUGINS]: Loading OpenSim application plugin {0}", node.Path);
  317. IApplicationPlugin plugin = (IApplicationPlugin)node.CreateInstance();
  318. plugin.Initialise(this);
  319. m_plugins.Add(plugin);
  320. }
  321. // Start UDP servers
  322. //for (int i = 0; i < m_udpServers.Count; i++)
  323. //{
  324. // m_udpServers[i].ServerListener();
  325. // }
  326. //Run Startup Commands
  327. if (m_startupCommandsFile != String.Empty)
  328. {
  329. RunCommandScript(m_startupCommandsFile);
  330. }
  331. else
  332. {
  333. m_log.Info("[STARTUP]: No startup command script specified. Moving on...");
  334. }
  335. // Start timer script (run a script every xx seconds)
  336. if (m_timedScript != "disabled")
  337. {
  338. m_scriptTimer = new Timer();
  339. m_scriptTimer.Enabled = true;
  340. m_scriptTimer.Interval = (int)(1200 * 1000);
  341. m_scriptTimer.Elapsed += new ElapsedEventHandler(RunAutoTimerScript);
  342. }
  343. // We are done with startup
  344. PrintFileToConsole("startuplogo.txt");
  345. m_log.Info("[OPENSIM MAIN]: Startup complete, serving " + m_udpServers.Count.ToString() + " region(s)");
  346. }
  347. protected override void Initialize()
  348. {
  349. //
  350. // Called from base.StartUp()
  351. //
  352. m_httpServerPort = m_networkServersInfo.HttpListenerPort;
  353. IAssetServer assetServer;
  354. if (m_assetStorage == "db4o")
  355. {
  356. assetServer = new LocalAssetServer();
  357. }
  358. else if (m_assetStorage == "grid")
  359. {
  360. assetServer = new GridAssetClient(m_networkServersInfo.AssetURL);
  361. }
  362. else
  363. {
  364. SQLAssetServer sqlAssetServer = new SQLAssetServer(m_standaloneAssetPlugin);
  365. sqlAssetServer.LoadDefaultAssets();
  366. assetServer = sqlAssetServer;
  367. }
  368. m_assetCache = new AssetCache(assetServer);
  369. m_sceneManager.OnRestartSim += handleRestartRegion;
  370. }
  371. public LLUUID CreateUser(string tempfirstname, string templastname, string tempPasswd, uint regX, uint regY)
  372. {
  373. return m_commsManager.AddUser(tempfirstname,templastname,tempPasswd,regX,regY);
  374. }
  375. /// <summary>
  376. /// Execute the region creation process. This includes setting up scene infrastructure.
  377. /// </summary>
  378. /// <param name="regionInfo"></param>
  379. /// <param name="portadd_flag"></param>
  380. /// <returns></returns>
  381. public UDPServer CreateRegion(RegionInfo regionInfo, bool portadd_flag)
  382. {
  383. int port = regionInfo.InternalEndPoint.Port;
  384. // set initial RegionID to originRegionID in RegionInfo. (it needs for loding prims)
  385. regionInfo.originRegionID = regionInfo.RegionID;
  386. // set initial ServerURI
  387. regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName
  388. + ":" + regionInfo.InternalEndPoint.Port.ToString();
  389. regionInfo.HttpPort = m_httpServerPort;
  390. if ((proxyUrl.Length > 0) && (portadd_flag))
  391. {
  392. // set proxy url to RegionInfo
  393. regionInfo.proxyUrl = proxyUrl;
  394. Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName);
  395. }
  396. UDPServer udpServer;
  397. Scene scene = SetupScene(regionInfo, proxyOffset, out udpServer, m_permissions);
  398. m_log.Info("[MODULES]: Loading Region's modules");
  399. m_moduleLoader.PickupModules(scene, ".");
  400. //m_moduleLoader.PickupModules(scene, "ScriptEngines");
  401. //m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", m_scriptEngine), scene);
  402. if (string.IsNullOrEmpty(m_scriptEngine))
  403. {
  404. m_log.Info("[MODULES]: No script engien module specified");
  405. }
  406. else
  407. {
  408. m_log.Info("[MODULES]: Loading scripting engine modules");
  409. foreach (string module in m_scriptEngine.Split(','))
  410. {
  411. string mod = module.Trim(" \t".ToCharArray()); // Clean up name
  412. m_log.Info("[MODULES]: Loading scripting engine: " + mod);
  413. try
  414. {
  415. m_moduleLoader.LoadRegionModules(Path.Combine("ScriptEngines", mod), scene);
  416. }
  417. catch (Exception ex)
  418. {
  419. m_log.Error("[MODULES]: Failed to load script engine: " + ex.ToString());
  420. }
  421. }
  422. }
  423. m_moduleLoader.InitialiseSharedModules(scene);
  424. scene.SetModuleInterfaces();
  425. //moved these here as the terrain texture has to be created after the modules are initialized
  426. // and has to happen before the region is registered with the grid.
  427. scene.CreateTerrainTexture(true);
  428. scene.RegisterRegionWithGrid();
  429. //Server side object editing permissions checking
  430. scene.PermissionsMngr.BypassPermissions = !m_permissions;
  431. // We need to do this after we've initialized the scripting engines.
  432. scene.StartScripts();
  433. scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);
  434. scene.LandChannel.performParcelPrimCountUpdate();
  435. m_sceneManager.Add(scene);
  436. m_udpServers.Add(udpServer);
  437. m_regionData.Add(regionInfo);
  438. udpServer.ServerListener();
  439. return udpServer;
  440. }
  441. protected override StorageManager CreateStorageManager(string connectionstring)
  442. {
  443. return new StorageManager(m_storageDll, connectionstring, m_storagePersistPrimInventories);
  444. }
  445. protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager,
  446. AgentCircuitManager circuitManager)
  447. {
  448. PermissionManager permissionManager = new PermissionManager();
  449. SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager);
  450. return
  451. new Scene(regionInfo, circuitManager, permissionManager, m_commsManager, sceneGridService, m_assetCache,
  452. storageManager, m_httpServer,
  453. m_moduleLoader, m_dumpAssetsToFile, m_physicalPrim, m_see_into_region_from_neighbor);
  454. }
  455. public void handleRestartRegion(RegionInfo whichRegion)
  456. {
  457. m_log.Error("[OPENSIM MAIN]: Got restart signal from SceneManager");
  458. // Shutting down the UDP server
  459. bool foundUDPServer = false;
  460. int UDPServerElement = 0;
  461. for (int i = 0; i < m_udpServers.Count; i++)
  462. {
  463. if (m_udpServers[i].RegionHandle == whichRegion.RegionHandle)
  464. {
  465. UDPServerElement = i;
  466. foundUDPServer = true;
  467. break;
  468. }
  469. }
  470. if (foundUDPServer)
  471. {
  472. // m_udpServers[UDPServerElement].Server.End
  473. m_udpServers[UDPServerElement].Server.Close();
  474. m_udpServers.RemoveAt(UDPServerElement);
  475. }
  476. //Removing the region from the sim's database of regions..
  477. int RegionHandleElement = -1;
  478. for (int i = 0; i < m_regionData.Count; i++)
  479. {
  480. if (whichRegion.RegionHandle == m_regionData[i].RegionHandle)
  481. {
  482. RegionHandleElement = i;
  483. }
  484. }
  485. if (RegionHandleElement >= 0)
  486. {
  487. m_regionData.RemoveAt(RegionHandleElement);
  488. }
  489. CreateRegion(whichRegion, true);
  490. //UDPServer restartingRegion = CreateRegion(whichRegion);
  491. //restartingRegion.ServerListener();
  492. //m_sceneManager.SendSimOnlineNotification(restartingRegion.RegionHandle);
  493. }
  494. protected override ConsoleBase CreateConsole()
  495. {
  496. return new ConsoleBase("Region", this);
  497. }
  498. # region Setup methods
  499. protected override PhysicsScene GetPhysicsScene()
  500. {
  501. return GetPhysicsScene(m_physicsEngine, m_meshEngineName);
  502. }
  503. private class SimStatusHandler : IStreamedRequestHandler
  504. {
  505. public byte[] Handle(string path, Stream request)
  506. {
  507. return Encoding.UTF8.GetBytes("OK");
  508. }
  509. public string ContentType
  510. {
  511. get { return "text/plain"; }
  512. }
  513. public string HttpMethod
  514. {
  515. get { return "GET"; }
  516. }
  517. public string Path
  518. {
  519. get { return "/simstatus/"; }
  520. }
  521. }
  522. #endregion
  523. /// <summary>
  524. /// Performs any last-minute sanity checking and shuts down the region server
  525. /// </summary>
  526. public virtual void Shutdown()
  527. {
  528. if (proxyUrl.Length > 0)
  529. {
  530. Util.XmlRpcCommand(proxyUrl, "Stop");
  531. }
  532. if (m_startupCommandsFile != String.Empty)
  533. {
  534. RunCommandScript(m_shutdownCommandsFile);
  535. }
  536. m_log.Info("[SHUTDOWN]: Closing all threads");
  537. m_log.Info("[SHUTDOWN]: Killing listener thread");
  538. m_log.Info("[SHUTDOWN]: Killing clients");
  539. // TODO: implement this
  540. m_log.Info("[SHUTDOWN]: Closing console and terminating");
  541. m_sceneManager.Close();
  542. m_console.Close();
  543. Environment.Exit(0);
  544. }
  545. private void RunAutoTimerScript(object sender, EventArgs e)
  546. {
  547. if (m_timedScript != "disabled")
  548. {
  549. RunCommandScript(m_timedScript);
  550. }
  551. }
  552. #region Console Commands
  553. /// <summary>
  554. ///
  555. /// </summary>
  556. /// <param name="fileName"></param>
  557. private void RunCommandScript(string fileName)
  558. {
  559. m_log.Info("[COMMANDFILE]: Running " + fileName);
  560. if (File.Exists(fileName))
  561. {
  562. StreamReader readFile = File.OpenText(fileName);
  563. string currentCommand = String.Empty;
  564. while ((currentCommand = readFile.ReadLine()) != null)
  565. {
  566. if (currentCommand != String.Empty)
  567. {
  568. m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'");
  569. m_console.RunCommand(currentCommand);
  570. }
  571. }
  572. }
  573. else
  574. {
  575. m_log.Error("[COMMANDFILE]: Command script missing. Can not run commands");
  576. }
  577. }
  578. private void PrintFileToConsole(string fileName)
  579. {
  580. if (File.Exists(fileName))
  581. {
  582. StreamReader readFile = File.OpenText(fileName);
  583. string currentLine = String.Empty;
  584. while ((currentLine = readFile.ReadLine()) != null)
  585. {
  586. m_log.Info("[!]" + currentLine);
  587. }
  588. }
  589. }
  590. /// <summary>
  591. /// Runs commands issued by the server console from the operator
  592. /// </summary>
  593. /// <param name="command">The first argument of the parameter (the command)</param>
  594. /// <param name="cmdparams">Additional arguments passed to the command</param>
  595. public override void RunCmd(string command, string[] cmdparams)
  596. {
  597. base.RunCmd(command, cmdparams);
  598. switch (command)
  599. {
  600. case "clear-assets":
  601. m_assetCache.Clear();
  602. break;
  603. case "set-time":
  604. m_sceneManager.SetCurrentSceneTimePhase(Convert.ToInt32(cmdparams[0]));
  605. break;
  606. case "force-update":
  607. m_console.Notice("Updating all clients");
  608. m_sceneManager.ForceCurrentSceneClientUpdate();
  609. break;
  610. case "edit-scale":
  611. if (cmdparams.Length == 4)
  612. {
  613. m_sceneManager.HandleEditCommandOnCurrentScene(cmdparams);
  614. }
  615. break;
  616. case "debug":
  617. if (cmdparams.Length > 0)
  618. {
  619. Debug(cmdparams);
  620. }
  621. break;
  622. case "scene-debug":
  623. if (cmdparams.Length == 3)
  624. {
  625. if (m_sceneManager.CurrentScene == null)
  626. {
  627. m_console.Error("CONSOLE", "Please use 'change-region <regioname>' first");
  628. }
  629. else
  630. {
  631. m_sceneManager.CurrentScene.SetSceneCoreDebug(!System.Convert.ToBoolean(cmdparams[0]), !System.Convert.ToBoolean(cmdparams[1]), !System.Convert.ToBoolean(cmdparams[2]));
  632. }
  633. }
  634. else
  635. {
  636. m_console.Error("scene-debug <scripting> <collisions> <physics> (where inside <> is true/false)");
  637. }
  638. break;
  639. case "help":
  640. m_console.Notice("alert - send alert to a designated user or all users.");
  641. m_console.Notice(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive.");
  642. m_console.Notice(" alert general [Message] - send an alert to all users.");
  643. m_console.Notice("backup - trigger a simulator backup");
  644. m_console.Notice("clear-assets - clear asset cache");
  645. m_console.Notice("create user - adds a new user.");
  646. m_console.Notice("change-region [name] - sets the region that many of these commands affect.");
  647. m_console.Notice("command-script [filename] - Execute command in a file.");
  648. m_console.Notice("debug - debugging commands");
  649. m_console.Notice(" packet 0..255 - print incoming/outgoing packets (0=off)");
  650. m_console.Notice("scene-debug [scripting] [collision] [physics] - Enable/Disable debug stuff, each can be True/False");
  651. m_console.Notice("edit-scale [prim name] [x] [y] [z] - resize given prim");
  652. m_console.Notice("export-map [filename] - save image of world map");
  653. m_console.Notice("force-update - force an update of prims in the scene");
  654. m_console.Notice("load-xml [filename] - load prims from XML");
  655. m_console.Notice("load-xml2 [filename] - load prims from XML using version 2 format");
  656. m_console.Notice("permissions [true/false] - turn on/off permissions on the scene");
  657. m_console.Notice("quit - equivalent to shutdown.");
  658. m_console.Notice("restart - disconnects all clients and restarts the sims in the instance.");
  659. m_console.Notice("remove-region [name] - remove a region");
  660. m_console.Notice("save-xml [filename] - save prims to XML");
  661. m_console.Notice("save-xml2 [filename] - save prims to XML using version 2 format");
  662. m_console.Notice("script - manually trigger scripts? or script commands?");
  663. m_console.Notice("set-time [x] - set the current scene time phase");
  664. m_console.Notice("show assets - show state of asset cache.");
  665. m_console.Notice("show users - show info about connected users.");
  666. m_console.Notice("show modules - shows info about loaded modules.");
  667. m_console.Notice("show stats - statistical information for this server not displayed in the client");
  668. m_console.Notice("threads - list threads");
  669. m_console.Notice("shutdown - disconnect all clients and shutdown.");
  670. m_console.Notice("config set section field value - set a config value");
  671. m_console.Notice("config get section field - get a config value");
  672. m_console.Notice("config save - save OpenSim.ini");
  673. m_console.Notice("terrain help - show help for terrain commands.");
  674. break;
  675. case "threads":
  676. // m_console.Notice("THREAD", Process.GetCurrentProcess().Threads.Count + " threads running:");
  677. // int _tc = 0;
  678. // foreach (ProcessThread pt in Process.GetCurrentProcess().Threads)
  679. // {
  680. // _tc++;
  681. // m_console.Notice("THREAD", _tc + ": ID: " + pt.Id + ", Started: " + pt.StartTime.ToString() + ", CPU time: " + pt.TotalProcessorTime + ", Pri: " + pt.BasePriority.ToString() + ", State: " + pt.ThreadState.ToString());
  682. // }
  683. List<Thread> threads = OpenSim.Framework.ThreadTracker.GetThreads();
  684. if (threads == null)
  685. {
  686. m_console.Notice("THREAD", "Thread tracking is only enabled in DEBUG mode.");
  687. }
  688. else
  689. {
  690. int _tc = 0;
  691. m_console.Notice("THREAD", threads.Count + " threads are being tracked:");
  692. foreach (Thread t in threads)
  693. {
  694. _tc++;
  695. m_console.Notice("THREAD", _tc + ": ID: " + t.ManagedThreadId.ToString() + ", Name: " + t.Name + ", Alive: " + t.IsAlive.ToString() + ", Pri: " + t.Priority.ToString() + ", State: " + t.ThreadState.ToString());
  696. }
  697. }
  698. break;
  699. case "save-xml":
  700. if (cmdparams.Length > 0)
  701. {
  702. m_sceneManager.SaveCurrentSceneToXml(cmdparams[0]);
  703. }
  704. else
  705. {
  706. m_sceneManager.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME);
  707. }
  708. break;
  709. case "load-xml":
  710. LLVector3 loadOffset = new LLVector3(0, 0, 0);
  711. if (cmdparams.Length > 0)
  712. {
  713. bool generateNewIDS = false;
  714. if (cmdparams.Length > 1)
  715. {
  716. if (cmdparams[1] == "-newUID")
  717. {
  718. generateNewIDS = true;
  719. }
  720. if (cmdparams.Length > 2)
  721. {
  722. loadOffset.X = (float) Convert.ToDecimal(cmdparams[2]);
  723. if (cmdparams.Length > 3)
  724. {
  725. loadOffset.Y = (float) Convert.ToDecimal(cmdparams[3]);
  726. }
  727. if (cmdparams.Length > 4)
  728. {
  729. loadOffset.Z = (float) Convert.ToDecimal(cmdparams[4]);
  730. }
  731. m_console.Error("loadOffsets <X,Y,Z> = <" + loadOffset.X + "," + loadOffset.Y + "," +
  732. loadOffset.Z + ">");
  733. }
  734. }
  735. m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS, loadOffset);
  736. }
  737. else
  738. {
  739. m_sceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset);
  740. }
  741. break;
  742. case "save-xml2":
  743. if (cmdparams.Length > 0)
  744. {
  745. m_sceneManager.SaveCurrentSceneToXml2(cmdparams[0]);
  746. }
  747. else
  748. {
  749. m_sceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME);
  750. }
  751. break;
  752. case "load-xml2":
  753. if (cmdparams.Length > 0)
  754. {
  755. m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[0]);
  756. }
  757. else
  758. {
  759. m_sceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME);
  760. }
  761. break;
  762. case "plugin":
  763. m_sceneManager.SendCommandToPluginModules(cmdparams);
  764. break;
  765. case "command-script":
  766. if (cmdparams.Length > 0)
  767. {
  768. RunCommandScript(cmdparams[0]);
  769. }
  770. break;
  771. case "permissions":
  772. // Treats each user as a super-admin when disabled
  773. bool permissions = Convert.ToBoolean(cmdparams[0]);
  774. m_sceneManager.SetBypassPermissionsOnCurrentScene(!permissions);
  775. break;
  776. case "backup":
  777. m_sceneManager.BackupCurrentScene();
  778. break;
  779. case "alert":
  780. m_sceneManager.HandleAlertCommandOnCurrentScene(cmdparams);
  781. break;
  782. case "create":
  783. CreateAccount(cmdparams);
  784. break;
  785. case "create-region":
  786. CreateRegion(new RegionInfo(cmdparams[0], "Regions/" + cmdparams[1],false), true);
  787. break;
  788. case "remove-region":
  789. string regName = CombineParams(cmdparams, 0);
  790. Scene killScene;
  791. if (m_sceneManager.TryGetScene(regName, out killScene))
  792. {
  793. if (m_sceneManager.CurrentScene.RegionInfo.RegionID == killScene.RegionInfo.RegionID)
  794. {
  795. m_sceneManager.TrySetCurrentScene("..");
  796. }
  797. m_regionData.Remove(killScene.RegionInfo);
  798. m_sceneManager.CloseScene(killScene);
  799. }
  800. break;
  801. case "quit":
  802. case "shutdown":
  803. Shutdown();
  804. break;
  805. case "restart":
  806. m_sceneManager.RestartCurrentScene();
  807. break;
  808. case "change-region":
  809. if (cmdparams.Length > 0)
  810. {
  811. string regionName = CombineParams(cmdparams, 0);
  812. if (!m_sceneManager.TrySetCurrentScene(regionName))
  813. {
  814. m_console.Error("Couldn't set current region to: " + regionName);
  815. }
  816. }
  817. if (m_sceneManager.CurrentScene == null)
  818. {
  819. m_console.Error("CONSOLE", "Currently at Root level. To change region please use 'change-region <regioname>'");
  820. }
  821. else
  822. {
  823. m_console.Error("CONSOLE", "Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName +
  824. ". To change region please use 'change-region <regioname>'");
  825. }
  826. break;
  827. case "export-map":
  828. if (cmdparams.Length > 0)
  829. {
  830. m_sceneManager.CurrentOrFirstScene.ExportWorldMap(cmdparams[0]);
  831. }
  832. else
  833. {
  834. m_sceneManager.CurrentOrFirstScene.ExportWorldMap("exportmap.jpg");
  835. }
  836. break;
  837. case "config":
  838. string n = command.ToUpper();
  839. if (cmdparams.Length > 0)
  840. {
  841. switch (cmdparams[0].ToLower())
  842. {
  843. case "set":
  844. if (cmdparams.Length < 4)
  845. {
  846. m_console.Error(n, "SYNTAX: " + n + " SET SECTION KEY VALUE");
  847. m_console.Error(n, "EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
  848. }
  849. else
  850. {
  851. IConfig c = DefaultConfig().Configs[cmdparams[1]];
  852. if (c == null)
  853. c = DefaultConfig().AddConfig(cmdparams[1]);
  854. string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
  855. c.Set(cmdparams[2], _value);
  856. m_config.Merge(c.ConfigSource);
  857. m_console.Error(n, n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " +
  858. _value);
  859. }
  860. break;
  861. case "get":
  862. if (cmdparams.Length < 3)
  863. {
  864. m_console.Error(n, "SYNTAX: " + n + " GET SECTION KEY");
  865. m_console.Error(n, "EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads");
  866. }
  867. else
  868. {
  869. IConfig c = DefaultConfig().Configs[cmdparams[1]];
  870. if (c == null)
  871. {
  872. m_console.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist.");
  873. break;
  874. }
  875. else
  876. {
  877. m_console.Notice(n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " +
  878. c.GetString(cmdparams[2]));
  879. }
  880. }
  881. break;
  882. case "save":
  883. m_console.Notice("Saving configuration file: " + Application.iniFilePath);
  884. m_config.Save(Application.iniFilePath);
  885. break;
  886. }
  887. }
  888. break;
  889. case "modules":
  890. if (cmdparams.Length > 0)
  891. {
  892. switch (cmdparams[0].ToLower())
  893. {
  894. case "list":
  895. foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules)
  896. {
  897. m_console.Notice("Shared region module: " + irm.Name);
  898. }
  899. break;
  900. case "unload":
  901. if (cmdparams.Length > 1)
  902. {
  903. foreach (IRegionModule rm in new System.Collections.ArrayList(m_moduleLoader.GetLoadedSharedModules))
  904. {
  905. if (rm.Name.ToLower() == cmdparams[1].ToLower())
  906. {
  907. m_console.Notice("Unloading module: " + rm.Name);
  908. m_moduleLoader.UnloadModule(rm);
  909. }
  910. }
  911. }
  912. break;
  913. case "load":
  914. if (cmdparams.Length > 1)
  915. {
  916. foreach (Scene s in new System.Collections.ArrayList(m_sceneManager.Scenes))
  917. {
  918. m_console.Notice("Loading module: " + cmdparams[1]);
  919. m_moduleLoader.LoadRegionModules(cmdparams[1], s);
  920. }
  921. }
  922. break;
  923. }
  924. }
  925. break;
  926. default:
  927. string[] tmpPluginArgs = new string[cmdparams.Length + 1];
  928. cmdparams.CopyTo(tmpPluginArgs, 1);
  929. tmpPluginArgs[0] = command;
  930. m_sceneManager.SendCommandToPluginModules(tmpPluginArgs);
  931. break;
  932. }
  933. }
  934. public void Debug(string[] args)
  935. {
  936. switch (args[0])
  937. {
  938. case "packet":
  939. if (args.Length > 1)
  940. {
  941. int newDebug;
  942. if (int.TryParse(args[1], out newDebug))
  943. {
  944. m_sceneManager.SetDebugPacketOnCurrentScene(newDebug);
  945. }
  946. else
  947. {
  948. m_console.Error("packet debug should be 0..2");
  949. }
  950. m_console.Notice("New packet debug: " + newDebug.ToString());
  951. }
  952. break;
  953. default:
  954. m_console.Error("Unknown debug");
  955. break;
  956. }
  957. }
  958. // see BaseOpenSimServer
  959. public override void Show(string ShowWhat)
  960. {
  961. base.Show(ShowWhat);
  962. switch (ShowWhat)
  963. {
  964. case "assets":
  965. m_assetCache.ShowState();
  966. break;
  967. case "users":
  968. m_console.Notice(
  969. String.Format("{0,-16}{1,-16}{2,-37}{3,-16}{4,-22}{5,-16}{6,-15}", "Firstname", "Lastname",
  970. "Agent ID", "Circuit", "IP", "Region", "Status"));
  971. foreach (ScenePresence presence in m_sceneManager.GetCurrentSceneAvatars())
  972. {
  973. RegionInfo regionInfo = m_sceneManager.GetRegionInfo(presence.RegionHandle);
  974. string regionName;
  975. System.Net.EndPoint ep = null;
  976. if (regionInfo == null)
  977. {
  978. regionName = "Unresolvable";
  979. }
  980. else
  981. {
  982. regionName = regionInfo.RegionName;
  983. }
  984. for (int i = 0; i < m_udpServers.Count; i++)
  985. {
  986. if (m_udpServers[i].RegionHandle == presence.RegionHandle)
  987. {
  988. m_udpServers[i].clientCircuits_reverse.TryGetValue(presence.ControllingClient.CircuitCode, out ep);
  989. }
  990. }
  991. m_console.Notice(
  992. String.Format(
  993. "{0,-16}{1,-16}{2,-37}{3,-16}{4,-22}{5,-16}{6,-15}",
  994. presence.Firstname,
  995. presence.Lastname,
  996. presence.UUID,
  997. presence.ControllingClient.CircuitCode,
  998. ep,
  999. regionName,
  1000. ((((ClientView)presence.ControllingClient).PacketProcessingEnabled)
  1001. ?"Active client":"Standby client")));
  1002. }
  1003. break;
  1004. case "modules":
  1005. m_console.Notice("The currently loaded shared modules are:");
  1006. foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules)
  1007. {
  1008. m_console.Notice("Shared Module: " + module.Name);
  1009. }
  1010. break;
  1011. case "regions":
  1012. m_sceneManager.ForEachScene(
  1013. delegate(Scene scene)
  1014. {
  1015. m_console.Notice("Region Name: " + scene.RegionInfo.RegionName + " , Region XLoc: " +
  1016. scene.RegionInfo.RegionLocX + " , Region YLoc: " +
  1017. scene.RegionInfo.RegionLocY);
  1018. });
  1019. break;
  1020. case "stats":
  1021. if (StatsManager.SimExtraStats != null)
  1022. {
  1023. m_console.Notice(
  1024. "STATS", Environment.NewLine + StatsManager.SimExtraStats.Report());
  1025. }
  1026. else
  1027. {
  1028. m_console.Notice("Extra sim statistics collection has not been enabled");
  1029. }
  1030. break;
  1031. }
  1032. }
  1033. private string CombineParams(string[] commandParams, int pos)
  1034. {
  1035. string result = String.Empty;
  1036. for (int i = pos; i < commandParams.Length; i++)
  1037. {
  1038. result += commandParams[i] + " ";
  1039. }
  1040. result = result.TrimEnd(' ');
  1041. return result;
  1042. }
  1043. #endregion
  1044. /// <summary>
  1045. /// Get the start time and up time of Region server
  1046. /// </summary>
  1047. /// <param name="starttime">The first out parameter describing when the Region server started</param>
  1048. /// <param name="uptime">The second out parameter describing how long the Region server has run</param>
  1049. public void GetRunTime(out string starttime, out string uptime)
  1050. {
  1051. starttime = m_startuptime.ToString();
  1052. uptime = (DateTime.Now - m_startuptime).ToString();
  1053. }
  1054. /// <summary>
  1055. /// Get the number of the avatars in the Region server
  1056. /// </summary>
  1057. /// <param name="usernum">The first out parameter describing the number of all the avatars in the Region server</param>
  1058. public void GetAvatarNumber(out int usernum)
  1059. {
  1060. usernum = m_sceneManager.GetCurrentSceneAvatars().Count;
  1061. }
  1062. /// <summary>
  1063. /// Get the number of the avatars in the Region server
  1064. /// </summary>
  1065. /// <param name="usernum">The first out parameter describing the number of all the avatars in the Region server</param>
  1066. public void GetRegionNumber(out int regionnum)
  1067. {
  1068. int accounter = 0;
  1069. //List<string> regionNameList = new List<string>();
  1070. m_sceneManager.ForEachScene(delegate(Scene scene) {
  1071. accounter++;
  1072. });
  1073. regionnum = accounter;
  1074. }
  1075. }
  1076. }