diff options
Diffstat (limited to 'samples/SimpleCalculatorSystem/CalculatorClient/Program.cs')
-rw-r--r-- | samples/SimpleCalculatorSystem/CalculatorClient/Program.cs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/samples/SimpleCalculatorSystem/CalculatorClient/Program.cs b/samples/SimpleCalculatorSystem/CalculatorClient/Program.cs new file mode 100644 index 0000000..09b209a --- /dev/null +++ b/samples/SimpleCalculatorSystem/CalculatorClient/Program.cs @@ -0,0 +1,33 @@ +using System; +using CalculatorCommonLib; +using Hik.Communication.Scs.Communication.EndPoints.Tcp; +using Hik.Communication.ScsServices.Client; + +namespace CalculatorClient +{ + class Program + { + static void Main() + { + Console.WriteLine("Press enter to connect to server and call methods..."); + Console.ReadLine(); + + //Create a client that can call methods of Calculator Service that is running on local computer and 10083 TCP port + //Since IScsServiceClient is IDisposible, it closes connection at the end of the using block + using (var client = ScsServiceClientBuilder.CreateClient<ICalculatorService>(new ScsTcpEndPoint("127.0.0.1", 10083))) + { + //Connect to the server + client.Connect(); + + //Call a remote method of server + var division = client.ServiceProxy.Divide(42, 3); + + //Write the result to the screen + Console.WriteLine("Result: " + division); + } + + Console.WriteLine("Press enter to stop client application"); + Console.ReadLine(); + } + } +} |