1.1 --- a/Server/MainForm.cs Wed Aug 13 23:02:40 2014 +0200
1.2 +++ b/Server/MainForm.cs Thu Aug 14 00:23:18 2014 +0200
1.3 @@ -22,11 +22,16 @@
1.4 System.Drawing.Bitmap iBmp;
1.5 bool iCreateBitmap; //Workaround render to bitmap issues when minimized
1.6 ServiceHost iServiceHost;
1.7 + /// <summary>
1.8 + /// Our collection of clients
1.9 + /// </summary>
1.10 + public Dictionary<string, IDisplayServiceCallback> iClients;
1.11
1.12 public MainForm()
1.13 {
1.14 LastTickTime = DateTime.Now;
1.15 iDisplay = new Display();
1.16 + iClients = new Dictionary<string, IDisplayServiceCallback>();
1.17
1.18 InitializeComponent();
1.19 UpdateStatus();
1.20 @@ -360,9 +365,38 @@
1.21 public void StopServer()
1.22 {
1.23 //Tell connected client first? Is that possible?
1.24 + BroadcastCloseEvent();
1.25 iServiceHost.Close();
1.26 }
1.27
1.28 + public void BroadcastCloseEvent()
1.29 + {
1.30 + var inactiveClients = new List<string>();
1.31 + foreach (var client in iClients)
1.32 + {
1.33 + //if (client.Key != eventData.ClientName)
1.34 + {
1.35 + try
1.36 + {
1.37 + client.Value.OnServerClosing(/*eventData*/);
1.38 + }
1.39 + catch (Exception ex)
1.40 + {
1.41 + inactiveClients.Add(client.Key);
1.42 + }
1.43 + }
1.44 + }
1.45 +
1.46 + if (inactiveClients.Count > 0)
1.47 + {
1.48 + foreach (var client in inactiveClients)
1.49 + {
1.50 + iClients.Remove(client);
1.51 + }
1.52 + }
1.53 + }
1.54 +
1.55 +
1.56
1.57 }
1.58 }