Call SetServer on consoles reflectively to avoid having type checks in places where it tends to be forgotten to update them.

0.9.1.0-post-fixes
Melanie 2019-08-21 21:15:58 +01:00
parent 0fd17c08ae
commit 7e136c67fd
5 changed files with 14 additions and 11 deletions

View File

@ -46,6 +46,8 @@ namespace OpenSim.Framework.Console
//
public class RemoteConsole : CommandConsole
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// Connection specific data, indexed by a session ID
// we create when a client connects.
protected class ConsoleConnection

0
OpenSim/Framework/ICommandConsole.cs Normal file → Executable file
View File

View File

@ -38,7 +38,7 @@ namespace OpenSim.Framework
string Prompt(string p, string def = null, List<char> excludedCharacters = null, bool echo = true);
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
// Displays a prompt and returns a default value, user may only enter 1 of 2 options
string Prompt(string prompt, string defaultresponse, List<string> options);
}
}

View File

@ -49,6 +49,7 @@ using OpenSim.Framework.Monitoring;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using OpenSim.Framework.Servers.HttpServer;
namespace OpenSim
{
@ -228,16 +229,14 @@ namespace OpenSim
m_log.InfoFormat("[OPENSIM] Enabling remote managed stats fetch. URL = {0}", urlBase);
}
if (m_console is RemoteConsole)
MethodInfo mi = m_console.GetType().GetMethod("SetServer", BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(BaseHttpServer) }, null);
if (mi != null)
{
if (m_consolePort == 0)
{
((RemoteConsole)m_console).SetServer(m_httpServer);
}
mi.Invoke(m_console, new object[] { m_httpServer });
else
{
((RemoteConsole)m_console).SetServer(MainServer.GetHttpServer(m_consolePort));
}
mi.Invoke(m_console, new object[] { MainServer.GetHttpServer(m_consolePort) });
}
// Hook up to the watchdog timer

8
OpenSim/Server/Base/HttpServerBase.cs Normal file → Executable file
View File

@ -149,12 +149,14 @@ namespace OpenSim.Server.Base
MainServer.RegisterHttpConsoleCommands(MainConsole.Instance);
if (MainConsole.Instance is RemoteConsole)
MethodInfo mi = m_console.GetType().GetMethod("SetServer", BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(BaseHttpServer) }, null);
if (mi != null)
{
if (m_consolePort == 0)
((RemoteConsole)MainConsole.Instance).SetServer(MainServer.Instance);
mi.Invoke(MainConsole.Instance, new object[] { MainServer.Instance });
else
((RemoteConsole)MainConsole.Instance).SetServer(MainServer.GetHttpServer(m_consolePort));
mi.Invoke(MainConsole.Instance, new object[] { MainServer.GetHttpServer(m_consolePort) });
}
}
}