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@55: using SharpDisplay;
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@31: [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
sl@55: public class Callback : ICallback, IDisposable
sl@20: {
sl@31: private MainForm MainForm { get; set; }
sl@31:
sl@31: public Callback(MainForm aMainForm)
sl@31: {
sl@31: MainForm = aMainForm;
sl@31: }
sl@31:
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@32: public void OnCloseOrder()
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@31: MainForm.CloseConnectionThreadSafe();
sl@31: MainForm.CloseThreadSafe();
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@31: [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
sl@55: public class Client : DuplexClientBase
sl@20: {
sl@30: public string Name { get; set; }
sl@30: public string SessionId { get { return InnerChannel.SessionId; } }
sl@26:
sl@57: public Client(ICallback aCallback)
sl@57: : base(new InstanceContext(aCallback), new NetTcpBinding(SecurityMode.None, true), new EndpointAddress("net.tcp://localhost:8001/DisplayService"))
sl@20: { }
sl@20:
sl@32: public void SetName(string aClientName)
sl@20: {
sl@26: Name = aClientName;
sl@32: Channel.SetName(aClientName);
sl@26: }
sl@26:
sl@62:
sl@62: public void SetLayout(TableLayout aLayout)
sl@62: {
sl@62: Channel.SetLayout(aLayout);
sl@62: }
sl@62:
sl@43: public void SetText(TextField aTextField)
sl@20: {
sl@43: Channel.SetText(aTextField);
sl@20: }
sl@20:
sl@43: public void SetTexts(System.Collections.Generic.IList aTextFields)
sl@20: {
sl@43: Channel.SetTexts(aTextFields);
sl@20: }
sl@20:
sl@67: public void SetBitmap(BitmapField aBitmapField)
sl@67: {
sl@67: Channel.SetBitmap(aBitmapField);
sl@67: }
sl@67:
sl@32: public int ClientCount()
sl@32: {
sl@32: return Channel.ClientCount();
sl@32: }
sl@57:
sl@57: public bool IsReady()
sl@57: {
sl@57: return State == CommunicationState.Opened;
sl@57: }
sl@20: }
sl@20: }