Adding server closing notification to clients.
2 using System.Windows.Forms;
3 using System.Collections;
4 using System.ServiceModel;
5 using System.Collections.Generic;
8 namespace SharpDisplayManager
11 /// Implement our display service.
12 /// This class is instantiated anew whenever a client send a request.
14 [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
15 class DisplayServer : IDisplayService
17 //From IDisplayService
18 public void SetTexts(System.Collections.Generic.IList<string> aTexts)
20 //Only support two lines for now
21 for (int i=0; i<aTexts.Count; i++)
25 Program.iMainForm.marqueeLabelTop.Text = aTexts[i];
29 Program.iMainForm.marqueeLabelBottom.Text = aTexts[i];
35 public void SetText(int aLineIndex, string aText)
37 //Only support two lines for now
40 Program.iMainForm.marqueeLabelTop.Text = aText;
42 else if (aLineIndex == 1)
44 Program.iMainForm.marqueeLabelBottom.Text = aText;
49 public void Connect(string aClientName)
51 IDisplayServiceCallback callback = OperationContext.Current.GetCallbackChannel<IDisplayServiceCallback>();
52 //remove the old client if any
53 if (Program.iMainForm.iClients.Keys.Contains(aClientName))
55 Program.iMainForm.iClients.Remove(aClientName);
58 Program.iMainForm.iClients.Add(aClientName, callback);
60 //For some reason MP still hangs on that one
61 //callback.OnConnected();