private void btnRegister_Click(object sender, EventArgs e) { if (Server == null) { int Port = Tools.GetRandom(5000, 50000); Server = new SMRAPI.HTTP(Port); Log.Write("{0}: Starting HTTP server on port {1}", GetType().Name, Port); Server.Start(); Server.ApiKeyEvent += delegate(object source, Guid Key) { Invoke((MethodInvoker) delegate { if (Key == Guid.Empty) { tbKey.Text = string.Empty; } else { tbKey.Text = Key.ToString(); } }); }; } Server.OpenBrowser(); }
private static void TestHTTP() { using (var L = new SMRAPI.HTTP(Tools.GetRandom(5000, 50000))) { L.StaticResources.Add("/favicon.ico", new SMRAPI.ResponseData(Tools.GetResource("SatisfactorySaveEditor.Images.Icons.edit.ico"))); L.ApiKeyEvent += delegate(object sender, Guid key) { Tools.E(key.ToString(), "HTTP event"); L.Stop(); }; L.Start(); L.OpenBrowser(); L.WaitForExit(); } }