public void StartServer() { m_log.Info("Start Server"); m_listening = true; // Where should this be checked? string controllerPath = "/" + m_options.controllerFilename; if (!HFTWebFileDB.GetInstance().FileExists(controllerPath)) { throw new System.ArgumentException( "\"Assets/WebPlayerTemplates/HappyFunTimes" + controllerPath + "\" does not exist. Did you forget to set \"controllerFilename\" in your \"PlayerSpawner\" or \"PlayerConnector\"?"); } #if UNITY_STANDALONE_OSX // TODO make 2 classes, one for running internal server, one for external? if (m_options.startExternalServer) { StartExternalServer(true); return; } #endif List <string> addresses = new List <string>(); addresses.Add("http://[::0]:" + m_options.serverPort); #if UNITY_STANDALONE_WIN addresses.Add("http://0.0.0.0:" + m_options.serverPort); #endif if (m_options.installationMode) { addresses.Add("http://[::0]:80"); #if UNITY_STANDALONE_WIN addresses.Add("http://0.0.0.0:80"); #endif } else { var hftOptions = new HFTSite.Options(); //hftOptions.port = ?? HFTUtil.SetIfNotNullOrEmpty(m_options.rendezvousUrl, ref hftOptions.rendezvousUrl); HFTUtil.SetIfNotNullOrEmpty(m_options.serverPort, ref hftOptions.port); m_hftSite = m_gameObject.AddComponent <HFTSite>(); m_hftSite.Init(hftOptions); } string ipv4Address = String.IsNullOrEmpty(m_options.ipv4DnsAddress) ? HFTIpUtils.GetLocalIPv4Address() : m_options.ipv4DnsAddress; string ipv6Address = String.IsNullOrEmpty(m_options.ipv6DnsAddress) ? HFTIpUtils.GetLocalIPv6Address() : m_options.ipv6DnsAddress; m_webServer = new HFTWebServer(m_options, addresses.ToArray()); m_webServer.Start(); if (m_options.dns || m_options.installationMode) { m_dnsRunner = new HFTDnsRunner(); m_dnsRunner.Start(ipv4Address, ipv6Address, 53); } }
// Use this for initialization void Start() { HFTLog.debug = HFTHappyFunTimesSettings.debug; Debug.Log("HFTDnsTest - start"); string ipv4Address = HFTIpUtils.GetLocalIPv4Address(); string ipv6Address = HFTIpUtils.GetLocalIPv6Address(); dnsRunner_ = new HFTDnsRunner(); dnsRunner_.Start(ipv4Address, ipv6Address, 4444); }
void Cleanup() { if (dnsRunner_ != null) { Debug.Log("HFTDnsTest - stop"); dnsRunner_.Stop(); dnsRunner_ = null; } }
public static int Main(string[] args) { HFTRuntimeOptions m_options; HFTArgParser p = HFTArgParser.GetInstance(); string argStr = ""; if (p.TryGet<string> ("hft-args", ref argStr)) { Deserializer d = new Deserializer(); m_options = d.Deserialize<HFTRuntimeOptions>(argStr); } else { m_options = new HFTRuntimeOptions (); } if (!HFTArgsToFields.Apply("hft", m_options)) { System.Console.WriteLine("bad args!"); return 1; } //using (System.IO.StreamWriter writer = new System.IO.StreamWriter(System.IO.File.Open("/Users/gregg/temp/hft-server.log", System.IO.FileMode.Create))) //{ // writer.WriteLine(System.DateTime.Now.ToString()); // writer.WriteLine(Serializer.Serialize(m_options, false, true)); //} List<string> addresses = new List<string>(); addresses.Add("http://[::0]:18679"); // addresses.Add("http://0.0.0.0:18679"); if (m_options.installationMode) { addresses.Add("http://[::0]:80"); // addresses.Add("http://0.0.0.0:80"); } // Do I want this option ever? // Good: Need from editor to test instalation mode in editor // Bad: If game is hacked and serve any folder. But if game // is hack you can probably own machine anyway. if (!String.IsNullOrEmpty(m_options.dataPath)) { HFTWebFileDB.GetInstance().DataPath = m_options.dataPath; } string ipv4Address = String.IsNullOrEmpty(m_options.ipv4DnsAddress) ? HFTIpUtils.GetLocalIPv4Address() : m_options.ipv4DnsAddress; string ipv6Address = String.IsNullOrEmpty(m_options.ipv6DnsAddress) ? HFTIpUtils.GetLocalIPv6Address() : m_options.ipv6DnsAddress; HFTWebServer webServer = new HFTWebServer(m_options, addresses.ToArray()); webServer.Start(); if (m_options.dns || m_options.installationMode) { HFTDnsRunner dnsRunner = new HFTDnsRunner(); dnsRunner.Start(ipv4Address, ipv6Address, 53); } // There's no HFTSite because were in installationMode which means there's no internet System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite); return 0; }
public static int Main(string[] args) { HFTRuntimeOptions m_options; HFTArgParser p = HFTArgParser.GetInstance(); string argStr = ""; if (p.TryGet <string> ("hft-args", ref argStr)) { Deserializer d = new Deserializer(); m_options = d.Deserialize <HFTRuntimeOptions>(argStr); } else { m_options = new HFTRuntimeOptions(); } if (!HFTArgsToFields.Apply("hft", m_options)) { System.Console.WriteLine("bad args!"); return(1); } HFTLog.debug = m_options.debug; //using (System.IO.StreamWriter writer = new System.IO.StreamWriter(System.IO.File.Open("/Users/gregg/temp/hft-server.log", System.IO.FileMode.Create))) //{ // writer.WriteLine(System.DateTime.Now.ToString()); // writer.WriteLine(Serializer.Serialize(m_options, false, true)); //} List <string> addresses = new List <string>(); addresses.Add("http://[::0]:" + m_options.serverPort); // addresses.Add("http://0.0.0.0:18679"); if (m_options.installationMode) { addresses.Add("http://[::0]:80"); // addresses.Add("http://0.0.0.0:80"); } // Do I want this option ever? // Good: Need from editor to test instalation mode in editor // Bad: If game is hacked and serve any folder. But if game // is hack you can probably own machine anyway. if (!String.IsNullOrEmpty(m_options.dataPath)) { HFTWebFileDB.GetInstance().DataPath = m_options.dataPath; } string ipv4Address = String.IsNullOrEmpty(m_options.ipv4DnsAddress) ? HFTIpUtils.GetLocalIPv4Address() : m_options.ipv4DnsAddress; string ipv6Address = String.IsNullOrEmpty(m_options.ipv6DnsAddress) ? HFTIpUtils.GetLocalIPv6Address() : m_options.ipv6DnsAddress; HFTWebServer webServer = new HFTWebServer(m_options, addresses.ToArray()); webServer.Start(); if (m_options.dns || m_options.installationMode) { HFTDnsRunner dnsRunner = new HFTDnsRunner(); dnsRunner.Start(ipv4Address, ipv6Address, 53); } // There's no HFTSite because were in installationMode which means there's no internet System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite); return(0); }
public void StartServer() { m_log.Info("Start Server"); // Where should this be checked? string controllerPath = "/" + m_options.controllerFilename; if (!HFTWebFileDB.GetInstance().FileExists(controllerPath)) { throw new System.ArgumentException( "\"Assets/WebPlayerTemplates/HappyFunTimes" + controllerPath + "\" does not exist. Did you forget to set \"controllerFilename\" in your \"PlayerSpawner\" or \"PlayerConnector\"?"); } #if UNITY_STANDALONE_OSX // TODO make 2 classes, one for running internal server, one for external? if (m_options.startExternalServer) { StartExternalServer(true); return; } #endif List<string> addresses = new List<string>(); addresses.Add("http://[::0]:18679"); // addresses.Add("http://0.0.0.0:18679"); if (m_options.installationMode) { addresses.Add("http://[::0]:80"); // addresses.Add("http://0.0.0.0:80"); } else { var hftOptions = new HFTSite.Options(); //hftOptions.port = ?? HFTUtil.SetIfNotNullOrEmpty(m_options.rendezvousUrl, ref hftOptions.rendezvousUrl); HFTUtil.SetIfNotNullOrEmpty(m_options.serverPort, ref hftOptions.port); m_hftSite = m_gameObject.AddComponent<HFTSite>(); m_hftSite.Init(hftOptions); } string ipv4Address = String.IsNullOrEmpty(m_options.ipv4DnsAddress) ? HFTIpUtils.GetLocalIPv4Address() : m_options.ipv4DnsAddress; string ipv6Address = String.IsNullOrEmpty(m_options.ipv6DnsAddress) ? HFTIpUtils.GetLocalIPv6Address() : m_options.ipv6DnsAddress; m_webServer = new HFTWebServer(m_options, addresses.ToArray()); m_webServer.Start(); if (m_options.dns || m_options.installationMode) { m_dnsRunner = new HFTDnsRunner(); m_dnsRunner.Start(ipv4Address, ipv6Address, 53); } }
public void StopServer() { CleanupCheck(); if (m_webServerProcess != null) { m_webServerProcess.Kill(); } if (m_hftSite != null) { m_hftSite.Stop(); Component.Destroy(m_hftSite); m_hftSite = null; } if (m_webServer != null) { m_webServer.Stop(); m_webServer = null; } if (m_dnsRunner != null) { m_dnsRunner.Stop(); m_dnsRunner = null; } }