aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn/ServerManager.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-04-02 18:29:42 -0400
committerMichael <[email protected]>2017-04-02 18:29:42 -0400
commit2612721346bc59807c4963d5e8c2f936852aa48b (patch)
treec8436d25f47afffed3d3f8943ee03c5a1b25d5b7 /ShiftOS_TheReturn/ServerManager.cs
parent2ea24d407ca5bad94bc17df7df33713e7734d415 (diff)
downloadshiftos_thereturn-2612721346bc59807c4963d5e8c2f936852aa48b.tar.gz
shiftos_thereturn-2612721346bc59807c4963d5e8c2f936852aa48b.tar.bz2
shiftos_thereturn-2612721346bc59807c4963d5e8c2f936852aa48b.zip
Reconnect to MUD after unexpected loss
Diffstat (limited to 'ShiftOS_TheReturn/ServerManager.cs')
-rw-r--r--ShiftOS_TheReturn/ServerManager.cs20
1 files changed, 19 insertions, 1 deletions
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;