From 9058ec53cc2e01ad3cba2e8387e81a14bd7dfa3e Mon Sep 17 00:00:00 2001 From: d3agle Date: Sat, 4 Apr 2015 16:48:47 -0500 Subject: [PATCH] Form disposal on client disconnection Added disposal method to dispose of all userstate forms for client upon disconnection of the client from the server --- Server/Core/Server.cs | 2 ++ Server/Core/UserState.cs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Server/Core/Server.cs b/Server/Core/Server.cs index 23ca21d1..d8e56e26 100644 --- a/Server/Core/Server.cs +++ b/Server/Core/Server.cs @@ -264,6 +264,8 @@ namespace xServer.Core { _clients.Remove(s); OnClientState(s, false); + + s.Value.DisposeForms(); } } } diff --git a/Server/Core/UserState.cs b/Server/Core/UserState.cs index 5e5d8917..e63ed791 100644 --- a/Server/Core/UserState.cs +++ b/Server/Core/UserState.cs @@ -37,5 +37,23 @@ namespace xServer.Core LastDesktopSeen = true; LastDirectorySeen = true; } + + public void DisposeForms() + { + if (FrmRdp != null) + FrmRdp.Close(); + if (FrmTm != null) + FrmTm.Close(); + if (FrmFm != null) + FrmFm.Close(); + if (FrmSi != null) + FrmSi.Close(); + if (FrmSm != null) + FrmSm.Close(); + if (FrmRs != null) + FrmRs.Close(); + if (FrmStm != null) + FrmStm.Close(); + } } }