From cdfba45faaa9202c69bdfe1a2f9e92140e0ecdae Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 30 Apr 2017 17:50:50 -0400 Subject: unite stuffs --- ShiftOS_TheReturn/SaveSystem.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 3e68a70..4f4e9f5 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -266,12 +266,9 @@ namespace ShiftOS.Engine { if (Utils.FileExists(Paths.GetPath("user.dat"))) { - var userdat = JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.GetPath("user.dat"))); + string token = Utils.ReadAllText(Paths.GetPath("user.dat")); - ServerManager.SendMessage("mud_login", $@"{{ - username: ""{userdat.Username}"", - password: ""{userdat.Password}"" -}}"); + ServerManager.SendMessage("mud_token_login", token); } else { -- cgit v1.2.3 From aec0eff8187fadb7418892c076a88c9bd03b8ff0 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 30 Apr 2017 19:26:00 -0400 Subject: unite registration --- ShiftOS.WinForms/Oobe.cs | 16 +++++ ShiftOS.WinForms/UniteSignupDialog.Designer.cs | 37 ++++++++-- ShiftOS.WinForms/UniteSignupDialog.cs | 93 ++++++++++++++++++++++++++ ShiftOS_TheReturn/SaveSystem.cs | 9 +-- 4 files changed, 141 insertions(+), 14 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 35efca4..245d13e 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -263,6 +263,22 @@ You must join the digital society, rise up the ranks, and save us. { var signupDialog = new UniteSignupDialog((token) => { + ServerMessageReceived smr = null; + smr = (msg) => + { + ServerManager.MessageReceived -= smr; + if (msg.Name == "mud_savefile") + { + SaveSystem.CurrentSave = JsonConvert.DeserializeObject(msg.Contents); + SaveSystem.SaveGame(); + } + else + { + LinkSaveFile(token); + } + }; + ServerManager.MessageReceived += smr; + ServerManager.SendMessage("mud_token_login", token); }); AppearanceManager.SetupDialog(signupDialog); diff --git a/ShiftOS.WinForms/UniteSignupDialog.Designer.cs b/ShiftOS.WinForms/UniteSignupDialog.Designer.cs index 752f5c0..a1509d7 100644 --- a/ShiftOS.WinForms/UniteSignupDialog.Designer.cs +++ b/ShiftOS.WinForms/UniteSignupDialog.Designer.cs @@ -40,17 +40,20 @@ this.txtdisplay = new System.Windows.Forms.TextBox(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); + this.txtsysname = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // btnlogin // this.btnlogin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnlogin.Location = new System.Drawing.Point(462, 407); + this.btnlogin.Location = new System.Drawing.Point(462, 479); this.btnlogin.Name = "btnlogin"; this.btnlogin.Size = new System.Drawing.Size(75, 23); this.btnlogin.TabIndex = 11; this.btnlogin.Text = "Submit"; this.btnlogin.UseVisualStyleBackColor = true; + this.btnlogin.Click += new System.EventHandler(this.btnlogin_Click); // // txtpassword // @@ -94,10 +97,10 @@ this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(17, 36); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(84, 13); + this.label1.Size = new System.Drawing.Size(120, 13); this.label1.TabIndex = 6; this.label1.Tag = "header2"; - this.label1.Text = "Login to ShiftOS"; + this.label1.Text = "Create ShiftOS Account"; // // txtconfirm // @@ -141,16 +144,36 @@ this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.label6.Location = new System.Drawing.Point(20, 251); + this.label6.Location = new System.Drawing.Point(20, 267); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(517, 153); + this.label6.Size = new System.Drawing.Size(517, 209); this.label6.TabIndex = 16; this.label6.Text = resources.GetString("label6.Text"); // + // txtsysname + // + this.txtsysname.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtsysname.Location = new System.Drawing.Point(113, 223); + this.txtsysname.Name = "txtsysname"; + this.txtsysname.Size = new System.Drawing.Size(424, 20); + this.txtsysname.TabIndex = 18; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(17, 226); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(73, 13); + this.label7.TabIndex = 17; + this.label7.Text = "System name:"; + // // UniteSignupDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.txtsysname); + this.Controls.Add(this.label7); this.Controls.Add(this.label6); this.Controls.Add(this.txtdisplay); this.Controls.Add(this.label5); @@ -163,7 +186,7 @@ this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Name = "UniteSignupDialog"; - this.Size = new System.Drawing.Size(555, 447); + this.Size = new System.Drawing.Size(555, 519); this.ResumeLayout(false); this.PerformLayout(); @@ -182,5 +205,7 @@ private System.Windows.Forms.TextBox txtdisplay; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; + private System.Windows.Forms.TextBox txtsysname; + private System.Windows.Forms.Label label7; } } diff --git a/ShiftOS.WinForms/UniteSignupDialog.cs b/ShiftOS.WinForms/UniteSignupDialog.cs index 2f20d9f..a46a9b0 100644 --- a/ShiftOS.WinForms/UniteSignupDialog.cs +++ b/ShiftOS.WinForms/UniteSignupDialog.cs @@ -8,6 +8,8 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; +using Newtonsoft.Json; +using System.Net; namespace ShiftOS.WinForms { @@ -39,5 +41,96 @@ namespace ShiftOS.WinForms public void OnUpgrade() { } + + private void btnlogin_Click(object sender, EventArgs e) + { + string u = txtusername.Text; + string p = txtpassword.Text; + + if (string.IsNullOrWhiteSpace(u)) + { + Infobox.Show("Please enter a username.", "You must enter a proper email address."); + return; + } + + if (string.IsNullOrWhiteSpace(p)) + { + Infobox.Show("Please enter a password.", "You must enter a valid password."); + return; + } + + if(p != txtconfirm.Text) + { + Infobox.Show("Passwords don't match.", "The \"Password\" and \"Confirm\" boxes must match."); + return; + } + + if (string.IsNullOrWhiteSpace(txtdisplay.Text)) + { + Infobox.Show("Empty display name", "Please choose a proper display name."); + return; + } + + if (string.IsNullOrWhiteSpace(txtsysname.Text)) + { + Infobox.Show("Empty system name", "Please name your computer!"); + return; + } + + if(p.Length < 7) + { + Infobox.Show("Password error", "Your password must have at least 7 characters."); + return; + } + + if (!(p.Any(char.IsUpper) && + p.Any(char.IsLower) && + p.Any(char.IsDigit))) + { + Infobox.Show("Password error", "Your password must contain at least one uppercase, lowercase, digit and symbol character."); + return; + } + + if (!u.Contains("@")) + { + Infobox.Show("Valid email required.", "You must specify a valid email address."); + return; + } + + try + { + var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Register?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4&displayname=" + txtdisplay.Text + "&sysname=" + txtsysname.Text); + string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); + webrequest.Headers.Add("Authentication: Basic " + base64); + var response = webrequest.GetResponse(); + var str = response.GetResponseStream(); + var reader = new System.IO.StreamReader(str); + string result = reader.ReadToEnd(); + if (result.StartsWith("{")) + { + var exc = JsonConvert.DeserializeObject(result); + Infobox.Show("Error", exc.Message); + return; + } + reader.Close(); + str.Close(); + str.Dispose(); + response.Dispose(); + Callback?.Invoke(result); + AppearanceManager.Close(this); + } +#if DEBUG + catch (Exception ex) + { + Infobox.Show("Error", ex.ToString()); + } +#else + catch + { + Infobox.Show("Login failed.", "The login attempt failed due to an incorrect username and password pair."); + } +#endif + + } } } diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 4f4e9f5..bd9a14f 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -298,14 +298,7 @@ namespace ShiftOS.Engine Console.Write("{SE_SAVING}... "); if (SaveSystem.CurrentSave != null) { - string username = CurrentSave.Username; - string password = CurrentSave.Password; - - Utils.WriteAllText(Paths.GetPath("user.dat"), $@"{{ - username: ""{username}"", - password: ""{password}"" -}}"); - + Utils.WriteAllText(Paths.GetPath("user.dat"), CurrentSave.UniteAuthToken); ServerManager.SendMessage("mud_save", JsonConvert.SerializeObject(CurrentSave, Formatting.Indented)); } if (!Shiftorium.Silent) -- cgit v1.2.3 From a99711507970055e02dd678e613e9d8546e6742e Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 30 Apr 2017 20:28:31 -0400 Subject: fix unite login and add multiuser support --- ShiftOS.Objects/ClientSave.cs | 9 +++ ShiftOS.Objects/Save.cs | 2 + ShiftOS.WinForms/Applications/Terminal.cs | 1 + ShiftOS.WinForms/UniteLoginDialog.Designer.cs | 4 +- ShiftOS_TheReturn/SaveSystem.cs | 99 +++++++++++++++++++---- ShiftOS_TheReturn/TerminalBackend.cs | 110 ++++++++++++++++++-------- 6 files changed, 176 insertions(+), 49 deletions(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS.Objects/ClientSave.cs b/ShiftOS.Objects/ClientSave.cs index edbb7dc..fbe1044 100644 --- a/ShiftOS.Objects/ClientSave.cs +++ b/ShiftOS.Objects/ClientSave.cs @@ -34,5 +34,14 @@ namespace ShiftOS.Objects { public string Username { get; set; } public string Password { get; set; } + public UserPermissions Permissions { get; set; } + } + + public enum UserPermissions + { + Root, + Admin, + User, + Guest } } diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 7208de5..1adaf3b 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -93,6 +93,8 @@ namespace ShiftOS.Objects } return count; } + + public List Users = new List(); } public class SettingsObject : DynamicObject diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 3b1a020..d35f7e0 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -283,6 +283,7 @@ namespace ShiftOS.WinForms.Applications } TerminalBackend.LastCommand = text3; TextSent?.Invoke(text4); + TerminalBackend.SendText(text4); if (TerminalBackend.InStory == false) { if (text3 == "stop theme") diff --git a/ShiftOS.WinForms/UniteLoginDialog.Designer.cs b/ShiftOS.WinForms/UniteLoginDialog.Designer.cs index daf385b..f510393 100644 --- a/ShiftOS.WinForms/UniteLoginDialog.Designer.cs +++ b/ShiftOS.WinForms/UniteLoginDialog.Designer.cs @@ -51,9 +51,9 @@ this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(16, 82); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(58, 13); + this.label2.Size = new System.Drawing.Size(35, 13); this.label2.TabIndex = 1; - this.label2.Text = "Username:"; + this.label2.Text = "Email:"; // // label3 // diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index bd9a14f..2df914e 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -50,6 +50,9 @@ namespace ShiftOS.Engine { public static bool ShuttingDown = false; + public static ClientSave CurrentUser { get; set; } + + public static Save CurrentSave { get; set; } /// @@ -189,28 +192,96 @@ namespace ShiftOS.Engine Thread.Sleep(50); Console.WriteLine("{SYSTEM_INITIATED}"); + + + if(CurrentSave.Users.Count == 0) + { + CurrentSave.Users.Add(new ClientSave + { + Username = "root", + Password = "", + Permissions = UserPermissions.Root + }); + Console.WriteLine("No users found. Creating new user with username \"root\", with no password."); + } TerminalBackend.InStory = false; + + TerminalBackend.PrefixEnabled = false; + + Login: + string username = ""; + int progress = 0; + bool goback = false; + TextSentEventHandler ev = null; + ev = (text) => + { + if (progress == 0) + { + if (!string.IsNullOrWhiteSpace(text)) + { + if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + { + Console.WriteLine("User not found."); + goback = true; + progress++; + TerminalBackend.TextSent -= ev; + return; + } + username = text; + progress++; + } + else + { + Console.WriteLine("Username not provided."); + TerminalBackend.TextSent -= ev; + goback = true; + progress++; + } + } + else if (progress == 1) + { + var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); + if (user.Password == text) + { + Console.WriteLine("Welcome to ShiftOS."); + CurrentUser = user; + Thread.Sleep(2000); + progress++; + } + else + { + Console.WriteLine("Access denied."); + goback = true; + progress++; + } + TerminalBackend.TextSent -= ev; + } + }; + TerminalBackend.TextSent += ev; + Console.WriteLine(CurrentSave.SystemName + " login:"); + while(progress == 0) + { + Thread.Sleep(10); + } + if (goback) + goto Login; + Console.WriteLine("password:"); + while (progress == 1) + Thread.Sleep(10); + if (goback) + goto Login; + + TerminalBackend.PrefixEnabled = true; Shiftorium.LogOrphanedUpgrades = true; Desktop.InvokeOnWorkerThread(new Action(() => { ShiftOS.Engine.Scripting.LuaInterpreter.RunSft(Paths.GetPath("kernel.sft")); })); - Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); - if (CurrentSave.StoryPosition == 1) - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - TutorialManager.StartTutorial(); - })); - while (TutorialManager.IsInTutorial == true) { } - GameReady?.Invoke(); - } - else - { - GameReady?.Invoke(); - } + + Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); + GameReady?.Invoke(); } public delegate void EmptyEventHandler(); diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 318c818..3bfdeff 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -32,21 +32,26 @@ using System.Threading.Tasks; using Newtonsoft.Json; using static ShiftOS.Engine.SaveSystem; -namespace ShiftOS.Engine { - public static class TerminalBackend { +namespace ShiftOS.Engine +{ + public static class TerminalBackend + { public static event Action CommandProcessed; public static bool Elevated { get; set; } - public static Dictionary GetArgs(ref string text) { + public static Dictionary GetArgs(ref string text) + { bool shouldParse = false; int argStart = 0; - if (text.Contains("{")) { + if (text.Contains("{")) + { shouldParse = true; argStart = text.IndexOf('{'); } - if (shouldParse == false) { + if (shouldParse == false) + { string replacement = Regex.Replace(text, @"\t|\n|\r", ""); text = replacement + "{}"; shouldParse = true; @@ -61,15 +66,18 @@ namespace ShiftOS.Engine { public static string LastCommand = ""; - public static void InvokeCommand(string ns, string command, Dictionary arguments, bool isRemote = false) { - try { + public static void InvokeCommand(string ns, string command, Dictionary arguments, bool isRemote = false) + { + try + { if (string.IsNullOrWhiteSpace(ns)) return; bool commandWasClient = RunClient(ns, command, arguments, isRemote); - if (!commandWasClient && !string.IsNullOrWhiteSpace(ns)) { + if (!commandWasClient && !string.IsNullOrWhiteSpace(ns)) + { PrefixEnabled = false; ServerManager.SendMessage("script", $@"{{ @@ -80,23 +88,29 @@ namespace ShiftOS.Engine { } CommandProcessed?.Invoke(ns + "." + command, JsonConvert.SerializeObject(arguments)); - } catch (Exception ex) { + } + catch (Exception ex) + { Console.WriteLine($"Command parse error: {ex.Message}"); // This shouldn't ever be called now PrefixEnabled = true; } } - public static string GetSentArgs(Dictionary argss) { + public static string GetSentArgs(Dictionary argss) + { Dictionary args = new Dictionary(); - foreach (KeyValuePair arg in argss) { + foreach (KeyValuePair arg in argss) + { args[arg.Key] = arg.Value; } return JsonConvert.SerializeObject(args); } - public static void InvokeCommand(string text, bool isRemote = false) { - try { + public static void InvokeCommand(string text, bool isRemote = false) + { + try + { if (string.IsNullOrWhiteSpace(text)) return; @@ -104,7 +118,8 @@ namespace ShiftOS.Engine { bool commandWasClient = RunClient(text, args, isRemote); - if (!commandWasClient) { + if (!commandWasClient) + { PrefixEnabled = false; ServerManager.SendMessage("script", $@"{{ @@ -114,7 +129,9 @@ namespace ShiftOS.Engine { }}"); } CommandProcessed?.Invoke(text, GetSentArgs(args)); - } catch (Exception ex) { + } + catch (Exception ex) + { Console.WriteLine($"Command parse error: {ex.Message}"); PrefixEnabled = true; @@ -129,15 +146,18 @@ namespace ShiftOS.Engine { public static event EmptyEventHandler TerminalRequested; - internal static void OpenTerminal() { + internal static void OpenTerminal() + { TerminalRequested?.Invoke(); } - public static bool CanRunRemotely(MethodInfo mth, bool isRemote) { + public static bool CanRunRemotely(MethodInfo mth, bool isRemote) + { if (!isRemote) return true; - foreach (var attr in mth.GetCustomAttributes(false)) { + foreach (var attr in mth.GetCustomAttributes(false)) + { if (attr is RemoteLockAttribute) return false; } @@ -145,26 +165,32 @@ namespace ShiftOS.Engine { return true; } - public static bool RunClient(string ns, string cmd, Dictionary args, bool isRemote = false) { + public static bool RunClient(string ns, string cmd, Dictionary args, bool isRemote = false) + { return RunClient(ns + "." + cmd, args, isRemote); } - public static bool RunClient(string text, Dictionary argss, bool isRemote = false) { + public static bool RunClient(string text, Dictionary argss, bool isRemote = false) + { Dictionary args = new Dictionary(); - foreach (KeyValuePair arg in argss) { + foreach (KeyValuePair arg in argss) + { args[arg.Key] = arg.Value; } return RunClient(text, args, isRemote); } - public static bool RunClient(string text, Dictionary args, bool isRemote = false) { + public static bool RunClient(string text, Dictionary args, bool isRemote = false) + { latestCommmand = text; //Console.WriteLine(text + " " + "{" + string.Join(",", args.Select(kv => kv.Key + "=" + kv.Value).ToArray()) + "}" + " " + isRemote); - foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) { - try { + foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + try + { var asm = Assembly.LoadFile(asmExec); var types = asm.GetTypes(); @@ -315,7 +341,9 @@ namespace ShiftOS.Engine { } } - } else { + } + else + { Console.WriteLine(text + " cannot be ran in a remote session"); return true; } @@ -360,7 +388,8 @@ namespace ShiftOS.Engine { } } } - } catch { } + } + catch { } } return false; } @@ -375,7 +404,7 @@ namespace ShiftOS.Engine { ConsoleEx.ForegroundColor = ConsoleColor.Magenta; ConsoleEx.Bold = true; - Console.Write(SaveSystem.CurrentSave.Username); + Console.Write(SaveSystem.CurrentUser.Username); ConsoleEx.Bold = false; ConsoleEx.ForegroundColor = ConsoleColor.Gray; Console.Write("@"); @@ -410,26 +439,34 @@ namespace ShiftOS.Engine { string text3 = ""; string text4 = msg.Contents; - if (TerminalBackend.PrefixEnabled) { + if (TerminalBackend.PrefixEnabled) + { text3 = text4.Remove(0, $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length); } IsForwardingConsoleWrites = true; - if (TerminalBackend.InStory == false) { + if (TerminalBackend.InStory == false) + { TerminalBackend.InvokeCommand(text3, true); } - if (TerminalBackend.PrefixEnabled) { + if (TerminalBackend.PrefixEnabled) + { Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); } IsForwardingConsoleWrites = false; - } else if (msg.Name == "pleasewrite") { + } + else if (msg.Name == "pleasewrite") + { Console.Write(msg.Contents); - } else if (msg.Name == "handshake_from") { + } + else if (msg.Name == "handshake_from") + { var a = JsonConvert.DeserializeObject>(msg.Contents); string uName = a["username"] as string; string pass = a["password"] as string; string sys = a["sysname"] as string; string guid = msg.GUID; - if (SaveSystem.CurrentSave.Username == uName && SaveSystem.CurrentSave.Password == pass && CurrentSave.SystemName == sys) { + if (SaveSystem.CurrentSave.Username == uName && SaveSystem.CurrentSave.Password == pass && CurrentSave.SystemName == sys) + { ForwardGUID = guid; ServerManager.SendMessage("trm_handshake_accept", $@"{{ guid: ""{ServerManager.thisGuid}"", @@ -450,5 +487,12 @@ namespace ShiftOS.Engine { public static bool IsForwardingConsoleWrites { get; internal set; } public static string ForwardGUID { get; internal set; } + public static event TextSentEventHandler TextSent; + + public static void SendText(string text) + { + TextSent?.Invoke(text); + } + } } -- cgit v1.2.3 From 097afe3dfe6af3ed10753434c1475a8771b4d3c8 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 1 May 2017 14:56:56 -0400 Subject: Unbind save handshake after message receive. --- ShiftOS_TheReturn/SaveSystem.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'ShiftOS_TheReturn/SaveSystem.cs') diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 2df914e..a27b04f 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -159,17 +159,23 @@ namespace ShiftOS.Engine { KernelWatchdog.Log("mud_handshake", "handshake successful: kernel watchdog access code is \"" + ServerManager.thisGuid.ToString() + "\""); - ServerManager.MessageReceived += (msg) => + ServerMessageReceived savehandshake = null; + + savehandshake = (msg) => { if (msg.Name == "mud_savefile") { CurrentSave = JsonConvert.DeserializeObject(msg.Contents); + ServerManager.MessageReceived -= savehandshake; } else if (msg.Name == "mud_login_denied") { oobe.PromptForLogin(); + ServerManager.MessageReceived -= savehandshake; } }; + ServerManager.MessageReceived += savehandshake; + ReadSave(); -- cgit v1.2.3