Renaming and deleting files. Adding documentation.
authorsl
Sun, 21 Sep 2014 13:40:21 +0200
changeset 56e86d84480b32
parent 55 b5ed2e29be23
child 57 544132d07c3b
Renaming and deleting files. Adding documentation.
Interface/Interface.cs
Server/Servers.cs
Server/Services.cs
Server/Session.cs
Server/SharpDisplayManager.csproj
     1.1 --- a/Interface/Interface.cs	Sun Sep 21 13:15:52 2014 +0200
     1.2 +++ b/Interface/Interface.cs	Sun Sep 21 13:40:21 2014 +0200
     1.3 @@ -1,4 +1,8 @@
     1.4 -using System;
     1.5 +//
     1.6 +// Define a public API for both SharpDisplay client and server to use.
     1.7 +//
     1.8 +
     1.9 +using System;
    1.10  using System.Collections.Generic;
    1.11  using System.Linq;
    1.12  using System.Text;
    1.13 @@ -11,6 +15,9 @@
    1.14  
    1.15  namespace SharpDisplay
    1.16  {
    1.17 +    /// <summary>
    1.18 +    /// TextField can be send to our server to be displayed on the screen.
    1.19 +    /// </summary>
    1.20      [DataContract]
    1.21      public class TextField
    1.22      {
    1.23 @@ -38,7 +45,12 @@
    1.24          public ContentAlignment Alignment { get; set; }
    1.25      }
    1.26  
    1.27 -
    1.28 +    /// <summary>
    1.29 +    /// Define our SharpDisplay service.
    1.30 +    /// Clients and servers must implement it to communicate with one another.
    1.31 +    /// Through this service clients can send requests to a server.
    1.32 +    /// Through this service a server session can receive requests from a client.
    1.33 +    /// </summary>
    1.34      [ServiceContract(   CallbackContract = typeof(ICallback), SessionMode = SessionMode.Required)]
    1.35      public interface IService
    1.36      {
    1.37 @@ -76,7 +88,9 @@
    1.38  
    1.39      }
    1.40  
    1.41 -
    1.42 +    /// <summary>
    1.43 +    /// SharDisplay callback provides a means for a server to notify its clients.
    1.44 +    /// </summary>
    1.45      public interface ICallback
    1.46      {
    1.47          [OperationContract(IsOneWay = true)]
     2.1 --- a/Server/Servers.cs	Sun Sep 21 13:15:52 2014 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,79 +0,0 @@
     2.4 -using System;
     2.5 -using System.Windows.Forms;
     2.6 -using System.Collections;
     2.7 -using System.ServiceModel;
     2.8 -using System.Collections.Generic;
     2.9 -using System.Linq;
    2.10 -using System.Diagnostics;
    2.11 -using SharpDisplay;
    2.12 -
    2.13 -namespace SharpDisplay
    2.14 -{
    2.15 -    /// <summary>
    2.16 -    /// Implement our display services.
    2.17 -    /// Each client connection has such a session object server side.
    2.18 -    /// </summary>
    2.19 -    [ServiceBehavior(   
    2.20 -                        ConcurrencyMode = ConcurrencyMode.Multiple,
    2.21 -                        InstanceContextMode = InstanceContextMode.PerSession                       
    2.22 -                    )]
    2.23 -    class Session : IService, IDisposable
    2.24 -    {
    2.25 -        public string SessionId { get; set; }
    2.26 -        public string Name { get; set; }
    2.27 -
    2.28 -        Session()
    2.29 -        {
    2.30 -            Trace.TraceInformation("Server session opening.");
    2.31 -            //First save our session ID. It will be needed in Dispose cause our OperationContxt won't be available then.
    2.32 -            SessionId = OperationContext.Current.SessionId;
    2.33 -            ICallback callback = OperationContext.Current.GetCallbackChannel<ICallback>();
    2.34 -            //
    2.35 -            SharpDisplayManager.Program.iMainForm.AddClientThreadSafe(SessionId,callback);
    2.36 -
    2.37 -        }
    2.38 -
    2.39 -        public void Dispose()
    2.40 -        {
    2.41 -            Trace.TraceInformation("Server session closing.");
    2.42 -            SharpDisplayManager.Program.iMainForm.RemoveClientThreadSafe(SessionId);
    2.43 -        }
    2.44 -        
    2.45 -        //From IDisplayService
    2.46 -        public void SetTexts(System.Collections.Generic.IList<TextField> aTextFields)
    2.47 -        {
    2.48 -            SharpDisplayManager.Program.iMainForm.SetTextsThreadSafe(SessionId, aTextFields);
    2.49 -        }
    2.50 -
    2.51 -        //
    2.52 -        public void SetText(TextField aTextField)
    2.53 -        {
    2.54 -            SharpDisplayManager.Program.iMainForm.SetTextThreadSafe(SessionId, aTextField);
    2.55 -        }
    2.56 -
    2.57 -        //
    2.58 -        public void SetName(string aClientName)
    2.59 -        {
    2.60 -            Name = aClientName;
    2.61 -            SharpDisplayManager.Program.iMainForm.SetClientNameThreadSafe(SessionId, Name);
    2.62 -            //Disconnect(aClientName);
    2.63 -
    2.64 -            //Register our client and its callback interface
    2.65 -            //IDisplayServiceCallback callback = OperationContext.Current.GetCallbackChannel<IDisplayServiceCallback>();
    2.66 -            //Program.iMainForm.iClients.Add(aClientName, callback);
    2.67 -            //Program.iMainForm.treeViewClients.Nodes.Add(aClientName, aClientName);
    2.68 -            //For some reason MP still hangs on that one
    2.69 -            //callback.OnConnected();
    2.70 -        }
    2.71 -
    2.72 -        ///
    2.73 -        public int ClientCount()
    2.74 -        {
    2.75 -            return SharpDisplayManager.Program.iMainForm.iClients.Count;
    2.76 -        }
    2.77 -
    2.78 -        
    2.79 -
    2.80 -    }
    2.81 -
    2.82 -}
     3.1 --- a/Server/Services.cs	Sun Sep 21 13:15:52 2014 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,32 +0,0 @@
     3.4 -using System;
     3.5 -using System.ServiceModel;
     3.6 -using System.Collections;
     3.7 -
     3.8 -
     3.9 -namespace SharpDisplayManager
    3.10 -{
    3.11 -    /*
    3.12 -    [ServiceContract(CallbackContract = typeof(IDisplayServiceCallback))]
    3.13 -    public interface IDisplayService
    3.14 -    {
    3.15 -        [OperationContract(IsOneWay = true)]
    3.16 -        void Connect(string aClientName);
    3.17 -
    3.18 -        [OperationContract(IsOneWay = true)]
    3.19 -        void SetText(int aLineIndex, string aText);
    3.20 -
    3.21 -        [OperationContract(IsOneWay = true)]
    3.22 -        void SetTexts(System.Collections.Generic.IList<string> aTexts);
    3.23 -    }
    3.24 -
    3.25 -
    3.26 -    public interface IDisplayServiceCallback
    3.27 -    {
    3.28 -        [OperationContract(IsOneWay = true)]
    3.29 -        void OnConnected();
    3.30 -
    3.31 -        [OperationContract(IsOneWay = true)]
    3.32 -        void OnServerClosing();
    3.33 -    }
    3.34 -     */
    3.35 -}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/Server/Session.cs	Sun Sep 21 13:40:21 2014 +0200
     4.3 @@ -0,0 +1,79 @@
     4.4 +using System;
     4.5 +using System.Windows.Forms;
     4.6 +using System.Collections;
     4.7 +using System.ServiceModel;
     4.8 +using System.Collections.Generic;
     4.9 +using System.Linq;
    4.10 +using System.Diagnostics;
    4.11 +using SharpDisplay;
    4.12 +
    4.13 +namespace SharpDisplay
    4.14 +{
    4.15 +    /// <summary>
    4.16 +    /// Implement our display services.
    4.17 +    /// Each client connection has such a session object server side.
    4.18 +    /// </summary>
    4.19 +    [ServiceBehavior(   
    4.20 +                        ConcurrencyMode = ConcurrencyMode.Multiple,
    4.21 +                        InstanceContextMode = InstanceContextMode.PerSession                       
    4.22 +                    )]
    4.23 +    class Session : IService, IDisposable
    4.24 +    {
    4.25 +        public string SessionId { get; set; }
    4.26 +        public string Name { get; set; }
    4.27 +
    4.28 +        Session()
    4.29 +        {
    4.30 +            Trace.TraceInformation("Server session opening.");
    4.31 +            //First save our session ID. It will be needed in Dispose cause our OperationContxt won't be available then.
    4.32 +            SessionId = OperationContext.Current.SessionId;
    4.33 +            ICallback callback = OperationContext.Current.GetCallbackChannel<ICallback>();
    4.34 +            //
    4.35 +            SharpDisplayManager.Program.iMainForm.AddClientThreadSafe(SessionId,callback);
    4.36 +
    4.37 +        }
    4.38 +
    4.39 +        public void Dispose()
    4.40 +        {
    4.41 +            Trace.TraceInformation("Server session closing.");
    4.42 +            SharpDisplayManager.Program.iMainForm.RemoveClientThreadSafe(SessionId);
    4.43 +        }
    4.44 +        
    4.45 +        //From IDisplayService
    4.46 +        public void SetTexts(System.Collections.Generic.IList<TextField> aTextFields)
    4.47 +        {
    4.48 +            SharpDisplayManager.Program.iMainForm.SetTextsThreadSafe(SessionId, aTextFields);
    4.49 +        }
    4.50 +
    4.51 +        //
    4.52 +        public void SetText(TextField aTextField)
    4.53 +        {
    4.54 +            SharpDisplayManager.Program.iMainForm.SetTextThreadSafe(SessionId, aTextField);
    4.55 +        }
    4.56 +
    4.57 +        //
    4.58 +        public void SetName(string aClientName)
    4.59 +        {
    4.60 +            Name = aClientName;
    4.61 +            SharpDisplayManager.Program.iMainForm.SetClientNameThreadSafe(SessionId, Name);
    4.62 +            //Disconnect(aClientName);
    4.63 +
    4.64 +            //Register our client and its callback interface
    4.65 +            //IDisplayServiceCallback callback = OperationContext.Current.GetCallbackChannel<IDisplayServiceCallback>();
    4.66 +            //Program.iMainForm.iClients.Add(aClientName, callback);
    4.67 +            //Program.iMainForm.treeViewClients.Nodes.Add(aClientName, aClientName);
    4.68 +            //For some reason MP still hangs on that one
    4.69 +            //callback.OnConnected();
    4.70 +        }
    4.71 +
    4.72 +        ///
    4.73 +        public int ClientCount()
    4.74 +        {
    4.75 +            return SharpDisplayManager.Program.iMainForm.iClients.Count;
    4.76 +        }
    4.77 +
    4.78 +        
    4.79 +
    4.80 +    }
    4.81 +
    4.82 +}
     5.1 --- a/Server/SharpDisplayManager.csproj	Sun Sep 21 13:15:52 2014 +0200
     5.2 +++ b/Server/SharpDisplayManager.csproj	Sun Sep 21 13:40:21 2014 +0200
     5.3 @@ -101,8 +101,7 @@
     5.4      <Compile Include="MarqueeLabel.cs" />
     5.5      <Compile Include="Program.cs" />
     5.6      <Compile Include="Properties\AssemblyInfo.cs" />
     5.7 -    <Compile Include="Servers.cs" />
     5.8 -    <Compile Include="Services.cs" />
     5.9 +    <Compile Include="Session.cs" />
    5.10      <Compile Include="Settings.cs" />
    5.11      <Compile Include="Win32API.cs" />
    5.12      <Compile Include="WindowsHook.cs" />