summaryrefslogtreecommitdiffstats
path: root/samples/CustomWireProtocol/ClientApp/Program.cs
blob: 006c09a6f2263d6d12d5f9547986e01639d0dfae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using CommonLib;
using Hik.Communication.Scs.Client;
using Hik.Communication.Scs.Communication.EndPoints.Tcp;
using Hik.Communication.Scs.Communication.Messages;

/* This application is build to demonstrate a CUSTOM WIRE PROTOCOL usage with SCS framework.
 * This client application connects to a server and sends a message using MyWireProtocol class.
 */

namespace ClientApp
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine("Press enter to connect to server and say Hello world!");
            Console.ReadLine();

            using (var client = ScsClientFactory.CreateClient(new ScsTcpEndPoint("127.0.0.1", 10033)))
            {
                client.WireProtocol = new MyWireProtocol(); //Set custom wire protocol!

                client.Connect();
                client.SendMessage(new ScsTextMessage("Hello world!"));

                Console.WriteLine("Press enter to disconnect from server");
                Console.ReadLine();
            }
        }
    }
}