public HFTWebServer(HFTRuntimeOptions options, string[] addresses)
{
m_log = new HFTLog("HFTWebServer");
m_options = options;
m_gamePath = "/";
m_webServerUtils = new HFTWebServerUtils(m_gamePath);
// Touch the HFTWebFileDB
// We do this be because we want it to get the list
// of files BEFORE run the server. The server will
// run in a different thread and HFTWebFileDB will
// not be able to populate its database from that thread.
HFTWebFileDB.GetInstance();
// FIX: sysname and gamename
string sysName = Environment.MachineName;
if (sysName.EndsWith(".local"))
{
sysName = sysName.Substring(0, sysName.Length - 6);
}
string gameName = m_options.name;
string ping = Serializer.Serialize(new HFTPing(sysName + ": " + gameName, "HappyFunTimes"));
m_ping = System.Text.Encoding.UTF8.GetBytes(ping);
m_log.Info("Ping: " + ping);
m_liveSettingsStr = "define([], function() { return " + Serializer.Serialize(new LiveSettings()) + "; })\n";
m_liveSettings = System.Text.Encoding.UTF8.GetBytes(m_liveSettingsStr);
if (options.captivePortal || options.installationMode)
{
m_captivePortalHandler = new HFTCaptivePortalHandler(m_webServerUtils);
m_getRouter.Add(m_captivePortalHandler.HandleRequest);
}
m_getRouter.Add(HandleRoot);
m_getRouter.Add(HandleLiveSettings);
m_getRouter.Add(HandleFile);
m_getRouter.Add(HandleMissingRoute);
m_getRouter.Add(HandleNotFound);
m_addresses = addresses;
}