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@26: public Client(InstanceContext callbackInstance)
sl@30: : base(callbackInstance, 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@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@32: public int ClientCount()
sl@32: {
sl@32: return Channel.ClientCount();
sl@32: }
sl@20: }
sl@20: }