# HG changeset patch # User sl # Date 1411299621 -7200 # Node ID e86d84480b327969b2f30764c37b07883f6e4d6f # Parent b5ed2e29be233b94bd43869bf1f637732f356426 Renaming and deleting files. Adding documentation. diff -r b5ed2e29be23 -r e86d84480b32 Interface/Interface.cs --- a/Interface/Interface.cs Sun Sep 21 13:15:52 2014 +0200 +++ b/Interface/Interface.cs Sun Sep 21 13:40:21 2014 +0200 @@ -1,4 +1,8 @@ -using System; +// +// Define a public API for both SharpDisplay client and server to use. +// + +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -11,6 +15,9 @@ namespace SharpDisplay { + /// + /// TextField can be send to our server to be displayed on the screen. + /// [DataContract] public class TextField { @@ -38,7 +45,12 @@ public ContentAlignment Alignment { get; set; } } - + /// + /// Define our SharpDisplay service. + /// Clients and servers must implement it to communicate with one another. + /// Through this service clients can send requests to a server. + /// Through this service a server session can receive requests from a client. + /// [ServiceContract( CallbackContract = typeof(ICallback), SessionMode = SessionMode.Required)] public interface IService { @@ -76,7 +88,9 @@ } - + /// + /// SharDisplay callback provides a means for a server to notify its clients. + /// public interface ICallback { [OperationContract(IsOneWay = true)] diff -r b5ed2e29be23 -r e86d84480b32 Server/Servers.cs --- a/Server/Servers.cs Sun Sep 21 13:15:52 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Collections; -using System.ServiceModel; -using System.Collections.Generic; -using System.Linq; -using System.Diagnostics; -using SharpDisplay; - -namespace SharpDisplay -{ - /// - /// Implement our display services. - /// Each client connection has such a session object server side. - /// - [ServiceBehavior( - ConcurrencyMode = ConcurrencyMode.Multiple, - InstanceContextMode = InstanceContextMode.PerSession - )] - class Session : IService, IDisposable - { - public string SessionId { get; set; } - public string Name { get; set; } - - Session() - { - Trace.TraceInformation("Server session opening."); - //First save our session ID. It will be needed in Dispose cause our OperationContxt won't be available then. - SessionId = OperationContext.Current.SessionId; - ICallback callback = OperationContext.Current.GetCallbackChannel(); - // - SharpDisplayManager.Program.iMainForm.AddClientThreadSafe(SessionId,callback); - - } - - public void Dispose() - { - Trace.TraceInformation("Server session closing."); - SharpDisplayManager.Program.iMainForm.RemoveClientThreadSafe(SessionId); - } - - //From IDisplayService - public void SetTexts(System.Collections.Generic.IList aTextFields) - { - SharpDisplayManager.Program.iMainForm.SetTextsThreadSafe(SessionId, aTextFields); - } - - // - public void SetText(TextField aTextField) - { - SharpDisplayManager.Program.iMainForm.SetTextThreadSafe(SessionId, aTextField); - } - - // - public void SetName(string aClientName) - { - Name = aClientName; - SharpDisplayManager.Program.iMainForm.SetClientNameThreadSafe(SessionId, Name); - //Disconnect(aClientName); - - //Register our client and its callback interface - //IDisplayServiceCallback callback = OperationContext.Current.GetCallbackChannel(); - //Program.iMainForm.iClients.Add(aClientName, callback); - //Program.iMainForm.treeViewClients.Nodes.Add(aClientName, aClientName); - //For some reason MP still hangs on that one - //callback.OnConnected(); - } - - /// - public int ClientCount() - { - return SharpDisplayManager.Program.iMainForm.iClients.Count; - } - - - - } - -} diff -r b5ed2e29be23 -r e86d84480b32 Server/Services.cs --- a/Server/Services.cs Sun Sep 21 13:15:52 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -using System; -using System.ServiceModel; -using System.Collections; - - -namespace SharpDisplayManager -{ - /* - [ServiceContract(CallbackContract = typeof(IDisplayServiceCallback))] - public interface IDisplayService - { - [OperationContract(IsOneWay = true)] - void Connect(string aClientName); - - [OperationContract(IsOneWay = true)] - void SetText(int aLineIndex, string aText); - - [OperationContract(IsOneWay = true)] - void SetTexts(System.Collections.Generic.IList aTexts); - } - - - public interface IDisplayServiceCallback - { - [OperationContract(IsOneWay = true)] - void OnConnected(); - - [OperationContract(IsOneWay = true)] - void OnServerClosing(); - } - */ -} diff -r b5ed2e29be23 -r e86d84480b32 Server/Session.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Server/Session.cs Sun Sep 21 13:40:21 2014 +0200 @@ -0,0 +1,79 @@ +using System; +using System.Windows.Forms; +using System.Collections; +using System.ServiceModel; +using System.Collections.Generic; +using System.Linq; +using System.Diagnostics; +using SharpDisplay; + +namespace SharpDisplay +{ + /// + /// Implement our display services. + /// Each client connection has such a session object server side. + /// + [ServiceBehavior( + ConcurrencyMode = ConcurrencyMode.Multiple, + InstanceContextMode = InstanceContextMode.PerSession + )] + class Session : IService, IDisposable + { + public string SessionId { get; set; } + public string Name { get; set; } + + Session() + { + Trace.TraceInformation("Server session opening."); + //First save our session ID. It will be needed in Dispose cause our OperationContxt won't be available then. + SessionId = OperationContext.Current.SessionId; + ICallback callback = OperationContext.Current.GetCallbackChannel(); + // + SharpDisplayManager.Program.iMainForm.AddClientThreadSafe(SessionId,callback); + + } + + public void Dispose() + { + Trace.TraceInformation("Server session closing."); + SharpDisplayManager.Program.iMainForm.RemoveClientThreadSafe(SessionId); + } + + //From IDisplayService + public void SetTexts(System.Collections.Generic.IList aTextFields) + { + SharpDisplayManager.Program.iMainForm.SetTextsThreadSafe(SessionId, aTextFields); + } + + // + public void SetText(TextField aTextField) + { + SharpDisplayManager.Program.iMainForm.SetTextThreadSafe(SessionId, aTextField); + } + + // + public void SetName(string aClientName) + { + Name = aClientName; + SharpDisplayManager.Program.iMainForm.SetClientNameThreadSafe(SessionId, Name); + //Disconnect(aClientName); + + //Register our client and its callback interface + //IDisplayServiceCallback callback = OperationContext.Current.GetCallbackChannel(); + //Program.iMainForm.iClients.Add(aClientName, callback); + //Program.iMainForm.treeViewClients.Nodes.Add(aClientName, aClientName); + //For some reason MP still hangs on that one + //callback.OnConnected(); + } + + /// + public int ClientCount() + { + return SharpDisplayManager.Program.iMainForm.iClients.Count; + } + + + + } + +} diff -r b5ed2e29be23 -r e86d84480b32 Server/SharpDisplayManager.csproj --- a/Server/SharpDisplayManager.csproj Sun Sep 21 13:15:52 2014 +0200 +++ b/Server/SharpDisplayManager.csproj Sun Sep 21 13:40:21 2014 +0200 @@ -101,8 +101,7 @@ - - +