Client/Server duplex is still a mess in C#.
2 using System.Windows.Forms;
3 using System.Collections;
4 using System.ServiceModel;
5 using System.Collections.Generic;
7 using SharpDisplayInterface;
9 namespace SharpDisplayManager
12 /// Implement our display service.
13 /// This class is instantiated anew whenever a client send a request.
15 [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
16 class DisplayServer : IDisplayService
18 //From IDisplayService
19 public void SetTexts(System.Collections.Generic.IList<string> aTexts)
21 //Only support two lines for now
22 for (int i=0; i<aTexts.Count; i++)
26 Program.iMainForm.marqueeLabelTop.Text = aTexts[i];
30 Program.iMainForm.marqueeLabelBottom.Text = aTexts[i];
36 public void SetText(int aLineIndex, string aText)
38 //Only support two lines for now
41 Program.iMainForm.marqueeLabelTop.Text = aText;
43 else if (aLineIndex == 1)
45 Program.iMainForm.marqueeLabelBottom.Text = aText;
50 public void Connect(string aClientName)
52 Disconnect(aClientName);
54 //Register our client and its callback interface
55 IDisplayServiceCallback callback = OperationContext.Current.GetCallbackChannel<IDisplayServiceCallback>();
56 Program.iMainForm.iClients.Add(aClientName, callback);
58 //For some reason MP still hangs on that one
59 //callback.OnConnected();
63 public void Disconnect(string aClientName)
65 //remove the old client if any
66 if (Program.iMainForm.iClients.Keys.Contains(aClientName))
68 Program.iMainForm.iClients.Remove(aClientName);