Still trying to setup WCF for us to work nicely.
Now using multi threading and reliable session.
Implementing thread safe functions where needed.
Enforcing session mode.
Fixing bug in marquee label as we forgot to reset current position when text is changed.
1.1 --- a/Client/Client.cs Thu Aug 14 18:37:23 2014 +0200
1.2 +++ b/Client/Client.cs Fri Aug 15 10:20:01 2014 +0200
1.3 @@ -14,7 +14,8 @@
1.4 /// <summary>
1.5 ///
1.6 /// </summary>
1.7 - public partial class Callback : IDisplayServiceCallback, IDisposable
1.8 + [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
1.9 + public class Callback : IDisplayServiceCallback, IDisposable
1.10 {
1.11 public void OnConnected()
1.12 {
1.13 @@ -46,12 +47,14 @@
1.14 /// <summary>
1.15 ///
1.16 /// </summary>
1.17 - public partial class Client : DuplexClientBase<IDisplayService>
1.18 + [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
1.19 + public class Client : DuplexClientBase<IDisplayService>
1.20 {
1.21 - private string Name { get; set; }
1.22 + public string Name { get; set; }
1.23 + public string SessionId { get { return InnerChannel.SessionId; } }
1.24
1.25 public Client(InstanceContext callbackInstance)
1.26 - : base(callbackInstance, new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8001/DisplayService"))
1.27 + : base(callbackInstance, new NetTcpBinding(SecurityMode.None, true), new EndpointAddress("net.tcp://localhost:8001/DisplayService"))
1.28 { }
1.29
1.30 public void Connect(string aClientName)
1.31 @@ -77,5 +80,7 @@
1.32 Channel.SetTexts(aTexts);
1.33 }
1.34
1.35 +
1.36 +
1.37 }
1.38 }
2.1 --- a/Client/MainForm.cs Thu Aug 14 18:37:23 2014 +0200
2.2 +++ b/Client/MainForm.cs Fri Aug 15 10:20:01 2014 +0200
2.3 @@ -27,7 +27,7 @@
2.4 {
2.5 //iClient.SetText(0,"Top");
2.6 //iClient.SetText(1, "Bottom");
2.7 - iClient.SetTexts(new string[] { "Top", "Bottom" });
2.8 + iClient.SetTexts(new string[] { iClient.Name, iClient.SessionId });
2.9 }
2.10
2.11 private void MainForm_Load(object sender, EventArgs e)
2.12 @@ -40,7 +40,8 @@
2.13 //Connect using unique name
2.14 string name = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt");
2.15 iClient.Connect(name);
2.16 - Text = Text + ": " + name;
2.17 + //Text = Text + ": " + name;
2.18 + Text = Text + ": " + iClient.SessionId;
2.19
2.20 }
2.21
3.1 --- a/Interface/Interface.cs Thu Aug 14 18:37:23 2014 +0200
3.2 +++ b/Interface/Interface.cs Fri Aug 15 10:20:01 2014 +0200
3.3 @@ -9,8 +9,9 @@
3.4
3.5 namespace SharpDisplayInterface
3.6 {
3.7 -
3.8 - [ServiceContract(CallbackContract = typeof(IDisplayServiceCallback))]
3.9 +
3.10 + [ServiceContract( CallbackContract = typeof(IDisplayServiceCallback),
3.11 + SessionMode = SessionMode.Required)]
3.12 public interface IDisplayService
3.13 {
3.14 [OperationContract(IsOneWay = true)]
4.1 --- a/Server/MainForm.Designer.cs Thu Aug 14 18:37:23 2014 +0200
4.2 +++ b/Server/MainForm.Designer.cs Fri Aug 15 10:20:01 2014 +0200
4.3 @@ -31,6 +31,7 @@
4.4 this.components = new System.ComponentModel.Container();
4.5 this.tabControl = new System.Windows.Forms.TabControl();
4.6 this.tabPageDisplay = new System.Windows.Forms.TabPage();
4.7 + this.buttonCloseClients = new System.Windows.Forms.Button();
4.8 this.checkBoxFixedPitchFontOnly = new System.Windows.Forms.CheckBox();
4.9 this.buttonSuspend = new System.Windows.Forms.Button();
4.10 this.buttonStartClient = new System.Windows.Forms.Button();
4.11 @@ -38,8 +39,6 @@
4.12 this.checkBoxConnectOnStartup = new System.Windows.Forms.CheckBox();
4.13 this.panelDisplay = new System.Windows.Forms.Panel();
4.14 this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
4.15 - this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
4.16 - this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
4.17 this.checkBoxShowBorders = new System.Windows.Forms.CheckBox();
4.18 this.trackBarBrightness = new System.Windows.Forms.TrackBar();
4.19 this.buttonFill = new System.Windows.Forms.Button();
4.20 @@ -56,13 +55,17 @@
4.21 this.toolStripStatusLabelSpring = new System.Windows.Forms.ToolStripStatusLabel();
4.22 this.toolStripStatusLabelPower = new System.Windows.Forms.ToolStripStatusLabel();
4.23 this.toolStripStatusLabelFps = new System.Windows.Forms.ToolStripStatusLabel();
4.24 - this.buttonCloseClients = new System.Windows.Forms.Button();
4.25 + this.tabPageClients = new System.Windows.Forms.TabPage();
4.26 + this.treeViewClients = new System.Windows.Forms.TreeView();
4.27 + this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
4.28 + this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
4.29 this.tabControl.SuspendLayout();
4.30 this.tabPageDisplay.SuspendLayout();
4.31 this.panelDisplay.SuspendLayout();
4.32 this.tableLayoutPanel.SuspendLayout();
4.33 ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit();
4.34 this.statusStrip.SuspendLayout();
4.35 + this.tabPageClients.SuspendLayout();
4.36 this.SuspendLayout();
4.37 //
4.38 // tabControl
4.39 @@ -72,6 +75,7 @@
4.40 | System.Windows.Forms.AnchorStyles.Right)));
4.41 this.tabControl.Controls.Add(this.tabPageDisplay);
4.42 this.tabControl.Controls.Add(this.tabPageTests);
4.43 + this.tabControl.Controls.Add(this.tabPageClients);
4.44 this.tabControl.Location = new System.Drawing.Point(12, 12);
4.45 this.tabControl.Name = "tabControl";
4.46 this.tabControl.SelectedIndex = 0;
4.47 @@ -103,6 +107,16 @@
4.48 this.tabPageDisplay.Text = "Display";
4.49 this.tabPageDisplay.UseVisualStyleBackColor = true;
4.50 //
4.51 + // buttonCloseClients
4.52 + //
4.53 + this.buttonCloseClients.Location = new System.Drawing.Point(7, 224);
4.54 + this.buttonCloseClients.Name = "buttonCloseClients";
4.55 + this.buttonCloseClients.Size = new System.Drawing.Size(75, 23);
4.56 + this.buttonCloseClients.TabIndex = 18;
4.57 + this.buttonCloseClients.Text = "Close Clients";
4.58 + this.buttonCloseClients.UseVisualStyleBackColor = true;
4.59 + this.buttonCloseClients.Click += new System.EventHandler(this.buttonCloseClients_Click);
4.60 + //
4.61 // checkBoxFixedPitchFontOnly
4.62 //
4.63 this.checkBoxFixedPitchFontOnly.AutoSize = true;
4.64 @@ -240,39 +254,6 @@
4.65 this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64);
4.66 this.tableLayoutPanel.TabIndex = 5;
4.67 //
4.68 - // marqueeLabelTop
4.69 - //
4.70 - this.marqueeLabelTop.AutoEllipsis = true;
4.71 - this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
4.72 - this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
4.73 - this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1);
4.74 - this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
4.75 - this.marqueeLabelTop.Name = "marqueeLabelTop";
4.76 - this.marqueeLabelTop.OwnTimer = false;
4.77 - this.marqueeLabelTop.PixelsPerSecond = 64;
4.78 - this.marqueeLabelTop.Separator = "|";
4.79 - this.marqueeLabelTop.Size = new System.Drawing.Size(254, 30);
4.80 - this.marqueeLabelTop.TabIndex = 2;
4.81 - this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
4.82 - this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
4.83 - this.marqueeLabelTop.UseCompatibleTextRendering = true;
4.84 - //
4.85 - // marqueeLabelBottom
4.86 - //
4.87 - this.marqueeLabelBottom.AutoEllipsis = true;
4.88 - this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
4.89 - this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 32);
4.90 - this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
4.91 - this.marqueeLabelBottom.Name = "marqueeLabelBottom";
4.92 - this.marqueeLabelBottom.OwnTimer = false;
4.93 - this.marqueeLabelBottom.PixelsPerSecond = 64;
4.94 - this.marqueeLabelBottom.Separator = null;
4.95 - this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 31);
4.96 - this.marqueeLabelBottom.TabIndex = 3;
4.97 - this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
4.98 - this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
4.99 - this.marqueeLabelBottom.UseCompatibleTextRendering = true;
4.100 - //
4.101 // checkBoxShowBorders
4.102 //
4.103 this.checkBoxShowBorders.AutoSize = true;
4.104 @@ -413,15 +394,57 @@
4.105 this.toolStripStatusLabelFps.Size = new System.Drawing.Size(26, 17);
4.106 this.toolStripStatusLabelFps.Text = "FPS";
4.107 //
4.108 - // buttonCloseClients
4.109 + // tabPageClients
4.110 //
4.111 - this.buttonCloseClients.Location = new System.Drawing.Point(7, 224);
4.112 - this.buttonCloseClients.Name = "buttonCloseClients";
4.113 - this.buttonCloseClients.Size = new System.Drawing.Size(75, 23);
4.114 - this.buttonCloseClients.TabIndex = 18;
4.115 - this.buttonCloseClients.Text = "Close Clients";
4.116 - this.buttonCloseClients.UseVisualStyleBackColor = true;
4.117 - this.buttonCloseClients.Click += new System.EventHandler(this.buttonCloseClients_Click);
4.118 + this.tabPageClients.Controls.Add(this.treeViewClients);
4.119 + this.tabPageClients.Location = new System.Drawing.Point(4, 22);
4.120 + this.tabPageClients.Name = "tabPageClients";
4.121 + this.tabPageClients.Padding = new System.Windows.Forms.Padding(3);
4.122 + this.tabPageClients.Size = new System.Drawing.Size(592, 369);
4.123 + this.tabPageClients.TabIndex = 2;
4.124 + this.tabPageClients.Text = "Clients";
4.125 + this.tabPageClients.UseVisualStyleBackColor = true;
4.126 + //
4.127 + // treeViewClients
4.128 + //
4.129 + this.treeViewClients.Location = new System.Drawing.Point(6, 6);
4.130 + this.treeViewClients.Name = "treeViewClients";
4.131 + this.treeViewClients.Size = new System.Drawing.Size(439, 357);
4.132 + this.treeViewClients.TabIndex = 0;
4.133 + this.treeViewClients.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewClients_AfterSelect);
4.134 + //
4.135 + // marqueeLabelTop
4.136 + //
4.137 + this.marqueeLabelTop.AutoEllipsis = true;
4.138 + this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
4.139 + this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
4.140 + this.marqueeLabelTop.Location = new System.Drawing.Point(1, 1);
4.141 + this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
4.142 + this.marqueeLabelTop.Name = "marqueeLabelTop";
4.143 + this.marqueeLabelTop.OwnTimer = false;
4.144 + this.marqueeLabelTop.PixelsPerSecond = 64;
4.145 + this.marqueeLabelTop.Separator = "|";
4.146 + this.marqueeLabelTop.Size = new System.Drawing.Size(254, 9);
4.147 + this.marqueeLabelTop.TabIndex = 2;
4.148 + this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
4.149 + this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
4.150 + this.marqueeLabelTop.UseCompatibleTextRendering = true;
4.151 + //
4.152 + // marqueeLabelBottom
4.153 + //
4.154 + this.marqueeLabelBottom.AutoEllipsis = true;
4.155 + this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
4.156 + this.marqueeLabelBottom.Location = new System.Drawing.Point(1, 21);
4.157 + this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
4.158 + this.marqueeLabelBottom.Name = "marqueeLabelBottom";
4.159 + this.marqueeLabelBottom.OwnTimer = false;
4.160 + this.marqueeLabelBottom.PixelsPerSecond = 64;
4.161 + this.marqueeLabelBottom.Separator = null;
4.162 + this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 20);
4.163 + this.marqueeLabelBottom.TabIndex = 3;
4.164 + this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
4.165 + this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
4.166 + this.marqueeLabelBottom.UseCompatibleTextRendering = true;
4.167 //
4.168 // MainForm
4.169 //
4.170 @@ -444,6 +467,7 @@
4.171 ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).EndInit();
4.172 this.statusStrip.ResumeLayout(false);
4.173 this.statusStrip.PerformLayout();
4.174 + this.tabPageClients.ResumeLayout(false);
4.175 this.ResumeLayout(false);
4.176 this.PerformLayout();
4.177
4.178 @@ -471,14 +495,16 @@
4.179 private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelPower;
4.180 private System.Windows.Forms.Panel panelDisplay;
4.181 private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
4.182 - public MarqueeLabel marqueeLabelTop;
4.183 - public MarqueeLabel marqueeLabelBottom;
4.184 + private MarqueeLabel marqueeLabelTop;
4.185 + private MarqueeLabel marqueeLabelBottom;
4.186 private System.Windows.Forms.CheckBox checkBoxConnectOnStartup;
4.187 private System.Windows.Forms.CheckBox checkBoxReverseScreen;
4.188 private System.Windows.Forms.Button buttonStartClient;
4.189 private System.Windows.Forms.Button buttonSuspend;
4.190 private System.Windows.Forms.CheckBox checkBoxFixedPitchFontOnly;
4.191 private System.Windows.Forms.Button buttonCloseClients;
4.192 + private System.Windows.Forms.TabPage tabPageClients;
4.193 + private System.Windows.Forms.TreeView treeViewClients;
4.194 }
4.195 }
4.196
5.1 --- a/Server/MainForm.cs Thu Aug 14 18:37:23 2014 +0200
5.2 +++ b/Server/MainForm.cs Fri Aug 15 10:20:01 2014 +0200
5.3 @@ -366,7 +366,7 @@
5.4 new Uri[] { new Uri("net.tcp://localhost:8001/") }
5.5 );
5.6
5.7 - iServiceHost.AddServiceEndpoint(typeof(IDisplayService), new NetTcpBinding(), "DisplayService");
5.8 + iServiceHost.AddServiceEndpoint(typeof(IDisplayService), new NetTcpBinding(SecurityMode.None,true), "DisplayService");
5.9 iServiceHost.Open();
5.10 }
5.11
5.12 @@ -407,6 +407,7 @@
5.13 foreach (var client in inactiveClients)
5.14 {
5.15 iClients.Remove(client);
5.16 + Program.iMainForm.treeViewClients.Nodes.Remove(Program.iMainForm.treeViewClients.Nodes.Find(client, false)[0]);
5.17 }
5.18 }
5.19 }
5.20 @@ -435,7 +436,122 @@
5.21 BroadcastCloseEvent();
5.22 }
5.23
5.24 + private void treeViewClients_AfterSelect(object sender, TreeViewEventArgs e)
5.25 + {
5.26
5.27 + }
5.28 +
5.29 + public delegate void AddClientDelegate(string aSessionId, IDisplayServiceCallback aCallback);
5.30 + public delegate void RemoveClientDelegate(string aSessionId);
5.31 + public delegate void SetTextDelegate(int aLineIndex, string aText);
5.32 + public delegate void SetTextsDelegate(System.Collections.Generic.IList<string> aTexts);
5.33 +
5.34 +
5.35 + /// <summary>
5.36 + ///
5.37 + /// </summary>
5.38 + /// <param name="aSessionId"></param>
5.39 + /// <param name="aCallback"></param>
5.40 + public void AddClientThreadSafe(string aSessionId, IDisplayServiceCallback aCallback)
5.41 + {
5.42 + if (this.treeViewClients.InvokeRequired)
5.43 + {
5.44 + //Not in the proper thread, invoke ourselves
5.45 + AddClientDelegate d = new AddClientDelegate(AddClientThreadSafe);
5.46 + this.Invoke(d, new object[] { aSessionId, aCallback });
5.47 + }
5.48 + else
5.49 + {
5.50 + //We are in the proper thread
5.51 + //Add this session to our collection of clients
5.52 + Program.iMainForm.iClients.Add(aSessionId, aCallback);
5.53 + //Add this session to our UI
5.54 + Program.iMainForm.treeViewClients.Nodes.Add(aSessionId, aSessionId);
5.55 + }
5.56 + }
5.57 +
5.58 + /// <summary>
5.59 + ///
5.60 + /// </summary>
5.61 + /// <param name="aSessionId"></param>
5.62 + public void RemoveClientThreadSafe(string aSessionId)
5.63 + {
5.64 + if (this.treeViewClients.InvokeRequired)
5.65 + {
5.66 + //Not in the proper thread, invoke ourselves
5.67 + RemoveClientDelegate d = new RemoveClientDelegate(RemoveClientThreadSafe);
5.68 + this.Invoke(d, new object[] { aSessionId });
5.69 + }
5.70 + else
5.71 + {
5.72 + //We are in the proper thread
5.73 + //Remove this session from both client collection and UI tree view
5.74 + if (Program.iMainForm.iClients.Keys.Contains(aSessionId))
5.75 + {
5.76 + Program.iMainForm.iClients.Remove(aSessionId);
5.77 + Program.iMainForm.treeViewClients.Nodes.Remove(Program.iMainForm.treeViewClients.Nodes.Find(aSessionId, false)[0]);
5.78 + }
5.79 + }
5.80 + }
5.81 +
5.82 + /// <summary>
5.83 + ///
5.84 + /// </summary>
5.85 + /// <param name="aLineIndex"></param>
5.86 + /// <param name="aText"></param>
5.87 + public void SetTextThreadSafe(int aLineIndex, string aText)
5.88 + {
5.89 + if (this.treeViewClients.InvokeRequired)
5.90 + {
5.91 + //Not in the proper thread, invoke ourselves
5.92 + SetTextDelegate d = new SetTextDelegate(SetTextThreadSafe);
5.93 + this.Invoke(d, new object[] { aLineIndex, aText });
5.94 + }
5.95 + else
5.96 + {
5.97 + //We are in the proper thread
5.98 + //Only support two lines for now
5.99 + if (aLineIndex == 0)
5.100 + {
5.101 + Program.iMainForm.marqueeLabelTop.Text = aText;
5.102 + }
5.103 + else if (aLineIndex == 1)
5.104 + {
5.105 + Program.iMainForm.marqueeLabelBottom.Text = aText;
5.106 + }
5.107 + }
5.108 + }
5.109 +
5.110 + /// <summary>
5.111 + ///
5.112 + /// </summary>
5.113 + /// <param name="aTexts"></param>
5.114 + public void SetTextsThreadSafe(System.Collections.Generic.IList<string> aTexts)
5.115 + {
5.116 + if (this.treeViewClients.InvokeRequired)
5.117 + {
5.118 + //Not in the proper thread, invoke ourselves
5.119 + SetTextsDelegate d = new SetTextsDelegate(SetTextsThreadSafe);
5.120 + this.Invoke(d, new object[] { aTexts });
5.121 + }
5.122 + else
5.123 + {
5.124 + //We are in the proper thread
5.125 + //Only support two lines for now
5.126 + for (int i = 0; i < aTexts.Count; i++)
5.127 + {
5.128 + if (i == 0)
5.129 + {
5.130 + Program.iMainForm.marqueeLabelTop.Text = aTexts[i];
5.131 + }
5.132 + else if (i == 1)
5.133 + {
5.134 + Program.iMainForm.marqueeLabelBottom.Text = aTexts[i];
5.135 + }
5.136 + }
5.137 + }
5.138 +
5.139 + }
5.140
5.141 }
5.142 }
6.1 --- a/Server/MarqueeLabel.cs Thu Aug 14 18:37:23 2014 +0200
6.2 +++ b/Server/MarqueeLabel.cs Fri Aug 15 10:20:01 2014 +0200
6.3 @@ -203,6 +203,7 @@
6.4
6.5 private void HandleTextSizeChange()
6.6 {
6.7 + CurrentPosition = 0;
6.8 //For all string measurements and drawing issues refer to the following article:
6.9 // http://stackoverflow.com/questions/1203087/why-is-graphics-measurestring-returning-a-higher-than-expected-number
6.10 //Update text size according to text and font
7.1 --- a/Server/Servers.cs Thu Aug 14 18:37:23 2014 +0200
7.2 +++ b/Server/Servers.cs Fri Aug 15 10:20:01 2014 +0200
7.3 @@ -5,6 +5,7 @@
7.4 using System.Collections.Generic;
7.5 using System.Linq;
7.6 using SharpDisplayInterface;
7.7 +using System.Diagnostics;
7.8
7.9 namespace SharpDisplayManager
7.10 {
7.11 @@ -12,49 +13,52 @@
7.12 /// Implement our display service.
7.13 /// This class is instantiated anew whenever a client send a request.
7.14 /// </summary>
7.15 - [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
7.16 - class DisplayServer : IDisplayService
7.17 + [ServiceBehavior(
7.18 + ConcurrencyMode = ConcurrencyMode.Multiple,
7.19 + InstanceContextMode = InstanceContextMode.PerSession
7.20 + )]
7.21 + class DisplayServer : IDisplayService, IDisposable
7.22 {
7.23 + public string SessionId { get; set; }
7.24 +
7.25 + DisplayServer()
7.26 + {
7.27 + Trace.TraceInformation("Server session opening.");
7.28 + //First save our session ID. It will be needed in Dispose cause our OperationContxt won't be available then.
7.29 + SessionId = OperationContext.Current.SessionId;
7.30 + IDisplayServiceCallback callback = OperationContext.Current.GetCallbackChannel<IDisplayServiceCallback>();
7.31 + //
7.32 + Program.iMainForm.AddClientThreadSafe(SessionId,callback);
7.33 +
7.34 + }
7.35 +
7.36 + public void Dispose()
7.37 + {
7.38 + Trace.TraceInformation("Server session closing.");
7.39 + Program.iMainForm.RemoveClientThreadSafe(SessionId);
7.40 + }
7.41 +
7.42 //From IDisplayService
7.43 public void SetTexts(System.Collections.Generic.IList<string> aTexts)
7.44 {
7.45 - //Only support two lines for now
7.46 - for (int i=0; i<aTexts.Count; i++)
7.47 - {
7.48 - if (i == 0)
7.49 - {
7.50 - Program.iMainForm.marqueeLabelTop.Text = aTexts[i];
7.51 - }
7.52 - else if (i == 1)
7.53 - {
7.54 - Program.iMainForm.marqueeLabelBottom.Text = aTexts[i];
7.55 - }
7.56 - }
7.57 + Program.iMainForm.SetTextsThreadSafe(aTexts);
7.58 }
7.59
7.60 //
7.61 public void SetText(int aLineIndex, string aText)
7.62 {
7.63 - //Only support two lines for now
7.64 - if (aLineIndex == 0)
7.65 - {
7.66 - Program.iMainForm.marqueeLabelTop.Text = aText;
7.67 - }
7.68 - else if (aLineIndex == 1)
7.69 - {
7.70 - Program.iMainForm.marqueeLabelBottom.Text = aText;
7.71 - }
7.72 + Program.iMainForm.SetTextThreadSafe(aLineIndex, aText);
7.73 }
7.74
7.75 //
7.76 public void Connect(string aClientName)
7.77 {
7.78 - Disconnect(aClientName);
7.79 + //Disconnect(aClientName);
7.80
7.81 //Register our client and its callback interface
7.82 - IDisplayServiceCallback callback = OperationContext.Current.GetCallbackChannel<IDisplayServiceCallback>();
7.83 - Program.iMainForm.iClients.Add(aClientName, callback);
7.84 -
7.85 + //IDisplayServiceCallback callback = OperationContext.Current.GetCallbackChannel<IDisplayServiceCallback>();
7.86 + //Program.iMainForm.iClients.Add(aClientName, callback);
7.87 + //Program.iMainForm.treeViewClients.Nodes.Add(aClientName, aClientName);
7.88 //For some reason MP still hangs on that one
7.89 //callback.OnConnected();
7.90 }
7.91 @@ -63,13 +67,17 @@
7.92 public void Disconnect(string aClientName)
7.93 {
7.94 //remove the old client if any
7.95 + /*
7.96 if (Program.iMainForm.iClients.Keys.Contains(aClientName))
7.97 {
7.98 Program.iMainForm.iClients.Remove(aClientName);
7.99 + Program.iMainForm.treeViewClients.Nodes.Remove(Program.iMainForm.treeViewClients.Nodes.Find(aClientName,false)[0]);
7.100 }
7.101 + */
7.102
7.103 }
7.104
7.105 +
7.106
7.107 }
7.108