From 2612721346bc59807c4963d5e8c2f936852aa48b Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 2 Apr 2017 18:29:42 -0400 Subject: Reconnect to MUD after unexpected loss --- ShiftOS_TheReturn/ServerManager.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'ShiftOS_TheReturn') diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 31b3129..4fce247 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -51,9 +51,11 @@ namespace ShiftOS.Engine public static Guid thisGuid { get; private set; } private static NetObjectClient client { get; set; } + private static bool UserDisconnect = false; public static void Disconnect() { + UserDisconnect = true; if (client != null) { client.Disconnect(); @@ -117,7 +119,23 @@ namespace ShiftOS.Engine public static void Initiate(string mud_address, int port) { client = new NetObjectClient(); - + client.OnDisconnected += (o, a) => + { + if (!UserDisconnect) + { + TerminalBackend.PrefixEnabled = true; + ConsoleEx.ForegroundColor = ConsoleColor.Red; + ConsoleEx.Bold = true; + Console.Write($@"Disconnected from MUD: "); + ConsoleEx.Bold = false; + ConsoleEx.Italic = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine("You have been disconnected from the multi-user domain for an unknown reason. Your save data is preserved within the kernel and you will be reconnected shortly."); + TerminalBackend.PrefixEnabled = true; + TerminalBackend.PrintPrompt(); + Initiate(mud_address, port); + } + }; client.OnReceived += (o, a) => { var msg = a.Data.Object as ServerMessage; -- cgit v1.2.3