Call SetServer on consoles reflectively to avoid having type checks in places where it tends to be forgotten to update them.
parent
0fd17c08ae
commit
7e136c67fd
|
@ -46,6 +46,8 @@ namespace OpenSim.Framework.Console
|
||||||
//
|
//
|
||||||
public class RemoteConsole : CommandConsole
|
public class RemoteConsole : CommandConsole
|
||||||
{
|
{
|
||||||
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
// Connection specific data, indexed by a session ID
|
// Connection specific data, indexed by a session ID
|
||||||
// we create when a client connects.
|
// we create when a client connects.
|
||||||
protected class ConsoleConnection
|
protected class ConsoleConnection
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
string Prompt(string p, string def = null, List<char> excludedCharacters = null, bool echo = true);
|
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);
|
string Prompt(string prompt, string defaultresponse, List<string> options);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -49,6 +49,7 @@ using OpenSim.Framework.Monitoring;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
|
|
||||||
namespace OpenSim
|
namespace OpenSim
|
||||||
{
|
{
|
||||||
|
@ -228,16 +229,14 @@ namespace OpenSim
|
||||||
m_log.InfoFormat("[OPENSIM] Enabling remote managed stats fetch. URL = {0}", urlBase);
|
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)
|
if (m_consolePort == 0)
|
||||||
{
|
mi.Invoke(m_console, new object[] { m_httpServer });
|
||||||
((RemoteConsole)m_console).SetServer(m_httpServer);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
mi.Invoke(m_console, new object[] { MainServer.GetHttpServer(m_consolePort) });
|
||||||
((RemoteConsole)m_console).SetServer(MainServer.GetHttpServer(m_consolePort));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hook up to the watchdog timer
|
// Hook up to the watchdog timer
|
||||||
|
|
|
@ -149,12 +149,14 @@ namespace OpenSim.Server.Base
|
||||||
|
|
||||||
MainServer.RegisterHttpConsoleCommands(MainConsole.Instance);
|
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)
|
if (m_consolePort == 0)
|
||||||
((RemoteConsole)MainConsole.Instance).SetServer(MainServer.Instance);
|
mi.Invoke(MainConsole.Instance, new object[] { MainServer.Instance });
|
||||||
else
|
else
|
||||||
((RemoteConsole)MainConsole.Instance).SetServer(MainServer.GetHttpServer(m_consolePort));
|
mi.Invoke(MainConsole.Instance, new object[] { MainServer.GetHttpServer(m_consolePort) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue