aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs152
1 files changed, 138 insertions, 14 deletions
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index bdefd0f..2c9e50e 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -33,8 +33,6 @@ using System.IO;
33using System.Text; 33using System.Text;
34using System.Threading; 34using System.Threading;
35using System.Timers; 35using System.Timers;
36using libsecondlife;
37using Mono.Addins;
38using Nini.Config; 36using Nini.Config;
39using OpenSim.Framework; 37using OpenSim.Framework;
40using OpenSim.Framework.Communications.Cache; 38using OpenSim.Framework.Communications.Cache;
@@ -49,6 +47,13 @@ using OpenSim.Region.Environment.Interfaces;
49using OpenSim.Region.Environment.Scenes; 47using OpenSim.Region.Environment.Scenes;
50using OpenSim.Region.Physics.Manager; 48using OpenSim.Region.Physics.Manager;
51using Timer=System.Timers.Timer; 49using Timer=System.Timers.Timer;
50using System.Net;
51using Nwc.XmlRpc;
52using System.Collections;
53using System.Reflection;
54using libsecondlife;
55using Mono.Addins;
56using Mono.Addins.Description;
52 57
53namespace OpenSim 58namespace OpenSim
54{ 59{
@@ -57,6 +62,8 @@ namespace OpenSim
57 public class OpenSimMain : RegionApplicationBase, conscmd_callback 62 public class OpenSimMain : RegionApplicationBase, conscmd_callback
58 { 63 {
59 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 64 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
65 private string proxyUrl;
66 private int proxyOffset = 0;
60 67
61 private const string DEFAULT_PRIM_BACKUP_FILENAME = "prim-backup.xml"; 68 private const string DEFAULT_PRIM_BACKUP_FILENAME = "prim-backup.xml";
62 69
@@ -110,6 +117,16 @@ namespace OpenSim
110 get { return m_httpServer; } 117 get { return m_httpServer; }
111 } 118 }
112 119
120 public List<UDPServer> UdpServers
121 {
122 get { return m_udpServers; }
123 }
124
125 public List<RegionInfo> RegionData
126 {
127 get { return m_regionData; }
128 }
129
113 private ModuleLoader m_moduleLoader; 130 private ModuleLoader m_moduleLoader;
114 131
115 public ModuleLoader ModuleLoader 132 public ModuleLoader ModuleLoader
@@ -350,20 +367,34 @@ namespace OpenSim
350 m_httpServer.AddStreamHandler(new SimStatusHandler()); 367 m_httpServer.AddStreamHandler(new SimStatusHandler());
351 } 368 }
352 369
370 proxyUrl = ConfigSource.Configs["Network"].GetString("proxy_url", "");
371 proxyOffset = Int32.Parse(ConfigSource.Configs["Network"].GetString("proxy_offset", "0"));
372
353 // Create a ModuleLoader instance 373 // Create a ModuleLoader instance
354 m_moduleLoader = new ModuleLoader(m_config); 374 m_moduleLoader = new ModuleLoader(m_config);
355 375
356 ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/Startup"); 376 ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/Startup");
357 m_log.InfoFormat("[PLUGINS]: Loading {0} OpenSim application plugins", nodes.Count); 377 m_log.InfoFormat("[PLUGINS]: Loading {0} OpenSim application plugins", nodes.Count);
358
359 foreach (TypeExtensionNode node in nodes) 378 foreach (TypeExtensionNode node in nodes)
360 { 379 {
361 IApplicationPlugin plugin = (IApplicationPlugin)node.CreateInstance(); 380 // First load the proxy server (if present)
362 381 if(node.Path.Contains("Proxy"))
363 plugin.Initialise(this); 382 {
364 m_plugins.Add(plugin); 383 IApplicationPlugin plugin = (IApplicationPlugin)node.CreateInstance();
384 plugin.Initialise(this);
385 m_plugins.Add(plugin);
386 }
387 }
388 // then load the other modules
389 foreach (TypeExtensionNode node in nodes)
390 {
391 if(!node.Path.Contains("Proxy"))
392 {
393 IApplicationPlugin plugin = (IApplicationPlugin)node.CreateInstance();
394 plugin.Initialise(this);
395 m_plugins.Add(plugin);
396 }
365 } 397 }
366
367 // Start UDP servers 398 // Start UDP servers
368 //for (int i = 0; i < m_udpServers.Count; i++) 399 //for (int i = 0; i < m_udpServers.Count; i++)
369 //{ 400 //{
@@ -436,10 +467,25 @@ namespace OpenSim
436 return m_commsManager.AddUser(tempfirstname,templastname,tempPasswd,regX,regY); 467 return m_commsManager.AddUser(tempfirstname,templastname,tempPasswd,regX,regY);
437 } 468 }
438 469
439 public UDPServer CreateRegion(RegionInfo regionInfo) 470 public UDPServer CreateRegion(RegionInfo regionInfo, bool portadd_flag)
440 { 471 {
472 int port = regionInfo.InternalEndPoint.Port;
473 if ((proxyOffset != 0) && (portadd_flag))
474 {
475 // set proxy url to RegionInfo
476 regionInfo.proxyUrl = proxyUrl;
477
478 // set initial RegionID to originRegionID in RegionInfo. (it needs for loding prims)
479 regionInfo.originRegionID = regionInfo.RegionID;
480
481 // set initial ServerURI
482 regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName
483 + ":" + regionInfo.InternalEndPoint.Port.ToString();
484
485 ProxyCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName);
486 }
441 UDPServer udpServer; 487 UDPServer udpServer;
442 Scene scene = SetupScene(regionInfo, out udpServer, m_permissions); 488 Scene scene = SetupScene(regionInfo, proxyOffset, out udpServer, m_permissions);
443 489
444 m_log.Info("[MODULES]: Loading Region's modules"); 490 m_log.Info("[MODULES]: Loading Region's modules");
445 491
@@ -546,7 +592,7 @@ namespace OpenSim
546 m_regionData.RemoveAt(RegionHandleElement); 592 m_regionData.RemoveAt(RegionHandleElement);
547 } 593 }
548 594
549 CreateRegion(whichRegion); 595 CreateRegion(whichRegion, true);
550 //UDPServer restartingRegion = CreateRegion(whichRegion); 596 //UDPServer restartingRegion = CreateRegion(whichRegion);
551 //restartingRegion.ServerListener(); 597 //restartingRegion.ServerListener();
552 //m_sceneManager.SendSimOnlineNotification(restartingRegion.RegionHandle); 598 //m_sceneManager.SendSimOnlineNotification(restartingRegion.RegionHandle);
@@ -594,6 +640,8 @@ namespace OpenSim
594 /// </summary> 640 /// </summary>
595 public virtual void Shutdown() 641 public virtual void Shutdown()
596 { 642 {
643 ProxyCommand(proxyUrl, "Stop");
644
597 if (m_startupCommandsFile != String.Empty) 645 if (m_startupCommandsFile != String.Empty)
598 { 646 {
599 RunCommandScript(m_shutdownCommandsFile); 647 RunCommandScript(m_shutdownCommandsFile);
@@ -609,7 +657,7 @@ namespace OpenSim
609 657
610 m_console.Close(); 658 m_console.Close();
611 Environment.Exit(0); 659 Environment.Exit(0);
612 } 660 }
613 661
614 private void RunAutoTimerScript(object sender, EventArgs e) 662 private void RunAutoTimerScript(object sender, EventArgs e)
615 { 663 {
@@ -882,9 +930,8 @@ namespace OpenSim
882 break; 930 break;
883 931
884 case "create-region": 932 case "create-region":
885 CreateRegion(new RegionInfo(cmdparams[0], "Regions/" + cmdparams[1],false)); 933 CreateRegion(new RegionInfo(cmdparams[0], "Regions/" + cmdparams[1],false), true);
886 break; 934 break;
887
888 case "remove-region": 935 case "remove-region":
889 string regName = CombineParams(cmdparams, 0); 936 string regName = CombineParams(cmdparams, 0);
890 937
@@ -1120,6 +1167,8 @@ namespace OpenSim
1120 presence.ControllingClient.CircuitCode, 1167 presence.ControllingClient.CircuitCode,
1121 ep, 1168 ep,
1122 regionName)); 1169 regionName));
1170 m_console.Notice(" {0}", (((ClientView)presence.ControllingClient).PacketProcessingEnabled)?"Active client":"Standby client");
1171
1123 } 1172 }
1124 1173
1125 break; 1174 break;
@@ -1167,5 +1216,80 @@ namespace OpenSim
1167 } 1216 }
1168 1217
1169 #endregion 1218 #endregion
1219 // TODO: remove me!! (almost same as XmlRpcCommand)
1220 public object ProxyCommand(string url, string methodName, params object[] args)
1221 {
1222 if(proxyUrl.Length==0) return null;
1223 return SendXmlRpcCommand(url, methodName, args);
1224 }
1225
1226 public object XmlRpcCommand(uint port, string methodName, params object[] args)
1227 {
1228 return SendXmlRpcCommand("http://localhost:"+port, methodName, args);
1229 }
1230
1231 public object XmlRpcCommand(string url, string methodName, params object[] args)
1232 {
1233 return SendXmlRpcCommand(url, methodName, args);
1234 }
1235
1236 private object SendXmlRpcCommand(string url, string methodName, object[] args)
1237 {
1238 try {
1239 //MainLog.Instance.Verbose("XMLRPC", "Sending command {0} to {1}", methodName, url);
1240 XmlRpcRequest client = new XmlRpcRequest(methodName, args);
1241 //MainLog.Instance.Verbose("XMLRPC", client.ToString());
1242 XmlRpcResponse response = client.Send(url, 6000);
1243 if(!response.IsFault) return response.Value;
1244 }
1245 catch(Exception e)
1246 {
1247 m_log.ErrorFormat("XMLRPC Failed to send command {0} to {1}: {2}", methodName, url, e.Message);
1248 }
1249 return null;
1250 }
1251
1252 /// <summary>
1253 /// Get the start time and up time of Region server
1254 /// </summary>
1255 /// <param name="starttime">The first out parameter describing when the Region server started</param>
1256 /// <param name="uptime">The second out parameter describing how long the Region server has run</param>
1257 public void GetRunTime(out string starttime, out string uptime)
1258 {
1259 starttime = m_startuptime.ToString();
1260 uptime = (DateTime.Now - m_startuptime).ToString();
1261 }
1262
1263 /// <summary>
1264 /// Get the number of the avatars in the Region server
1265 /// </summary>
1266 /// <param name="usernum">The first out parameter describing the number of all the avatars in the Region server</param>
1267 public void GetAvatarNumber(out int usernum)
1268 {
1269 int accounter = 0;
1270
1271 foreach (ScenePresence presence in m_sceneManager.GetCurrentSceneAvatars()) {
1272 //presence.RegionHandle;
1273 accounter++;
1274 }
1275
1276 usernum = accounter;
1277 }
1278
1279 /// <summary>
1280 /// Get the number of the avatars in the Region server
1281 /// </summary>
1282 /// <param name="usernum">The first out parameter describing the number of all the avatars in the Region server</param>
1283 public void GetRegionNumber(out int regionnum)
1284 {
1285 int accounter = 0;
1286 //List<string> regionNameList = new List<string>();
1287
1288 m_sceneManager.ForEachScene(delegate(Scene scene) {
1289 accounter++;
1290 });
1291 regionnum = accounter;
1292
1293 }
1170 } 1294 }
1171} 1295}