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

This commit is contained in:
Melanie
2019-08-21 21:15:58 +01:00
parent 0fd17c08ae
commit 7e136c67fd
5 changed files with 14 additions and 11 deletions

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