Client/Client.cs
author sl
Thu, 14 Aug 2014 00:23:18 +0200
changeset 21 274a6b27c3f9
parent 20 e3d394dd0388
child 22 cac466b1b6e6
permissions -rw-r--r--
Adding server closing notification to clients.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 using System.Windows.Forms;
     7 using SharpDisplayManager;
     8 using System.ServiceModel;
     9 using System.ServiceModel.Channels;
    10 
    11 
    12 namespace SharpDisplayClient
    13 {
    14     public partial class ClientInput : SharpDisplayManager.IDisplayServiceCallback
    15     {
    16         public void OnConnected()
    17         {
    18             //Debug.Assert(Thread.CurrentThread.IsThreadPoolThread);
    19             //Trace.WriteLine("Callback thread = " + Thread.CurrentThread.ManagedThreadId);
    20 
    21             MessageBox.Show("OnConnected()", "Client");
    22         }
    23 
    24 
    25         public void OnServerClosing()
    26         {
    27             //Debug.Assert(Thread.CurrentThread.IsThreadPoolThread);
    28             //Trace.WriteLine("Callback thread = " + Thread.CurrentThread.ManagedThreadId);
    29 
    30             //MessageBox.Show("OnServerClosing()", "Client");
    31             Program.iMainForm.CloseConnection();
    32         }
    33     }
    34 
    35 
    36 
    37     public partial class ClientOutput : DuplexClientBase<IDisplayService>, IDisplayService
    38     {
    39         public ClientOutput(InstanceContext callbackInstance)
    40             : base(callbackInstance, new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8001/DisplayService"))
    41         { }
    42 
    43         public void Connect(string aClientName)
    44         {
    45             Channel.Connect(aClientName);
    46         }
    47 
    48         public void SetText(int aLineIndex, string aText)
    49         {
    50             Channel.SetText(aLineIndex, aText);
    51         }
    52 
    53 
    54         public void SetTexts(System.Collections.Generic.IList<string> aTexts)
    55         {
    56             Channel.SetTexts(aTexts);
    57         }
    58 
    59 
    60     }
    61 }