sl@20: using System; sl@20: using System.Collections.Generic; sl@20: using System.Linq; sl@20: using System.Text; sl@20: using System.Threading.Tasks; sl@20: using System.Windows.Forms; sl@22: using SharpDisplayInterface; sl@20: using System.ServiceModel; sl@20: using System.ServiceModel.Channels; sl@20: sl@20: sl@20: namespace SharpDisplayClient sl@20: { sl@25: /// sl@25: /// sl@25: /// sl@26: public partial class Callback : IDisplayServiceCallback, IDisposable sl@20: { sl@20: public void OnConnected() sl@20: { sl@20: //Debug.Assert(Thread.CurrentThread.IsThreadPoolThread); sl@20: //Trace.WriteLine("Callback thread = " + Thread.CurrentThread.ManagedThreadId); sl@20: sl@20: MessageBox.Show("OnConnected()", "Client"); sl@20: } sl@20: sl@20: sl@20: public void OnServerClosing() sl@20: { sl@20: //Debug.Assert(Thread.CurrentThread.IsThreadPoolThread); sl@20: //Trace.WriteLine("Callback thread = " + Thread.CurrentThread.ManagedThreadId); sl@20: sl@21: //MessageBox.Show("OnServerClosing()", "Client"); sl@21: Program.iMainForm.CloseConnection(); sl@20: } sl@25: sl@25: //From IDisposable sl@25: public void Dispose() sl@25: { sl@25: sl@25: } sl@20: } sl@20: sl@20: sl@25: /// sl@25: /// sl@25: /// sl@26: public partial class Client : DuplexClientBase sl@20: { sl@26: private string Name { get; set; } sl@26: sl@26: public Client(InstanceContext callbackInstance) sl@20: : base(callbackInstance, new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8001/DisplayService")) sl@20: { } sl@20: sl@20: public void Connect(string aClientName) sl@20: { sl@26: Name = aClientName; sl@20: Channel.Connect(aClientName); sl@20: } sl@20: sl@26: public void Disconnect() sl@26: { sl@26: Channel.Disconnect(Name); sl@26: Name = ""; sl@26: } sl@26: sl@20: public void SetText(int aLineIndex, string aText) sl@20: { sl@20: Channel.SetText(aLineIndex, aText); sl@20: } sl@20: sl@20: sl@20: public void SetTexts(System.Collections.Generic.IList aTexts) sl@20: { sl@20: Channel.SetTexts(aTexts); sl@20: } sl@20: sl@20: } sl@20: }