using SwanCSharp.Sockets;
using System;
using System.Collections.Generic;
using System.Text;

namespace ClientSocket
{
    class Program
    {
        static void Main(string[] args)
        {
            SendCommand01();
            SendCommand02();
            SendCommand03();

            while (true)
            {
            }
        }

        private static void SendCommand01()
        {
            SocketClient lobjClient = new SocketClient("192.168.2.2", 5900);
            lobjClient.ReceiveData += new SocketClient.ReceiveDataEventHandler(lobjClient_ReceiveData);

            // Send command '01' + data
            lobjClient.SendData("01", "abcdefg");
            lobjClient.CerrarConexion();
        }

        private static void SendCommand02()
        {
            SocketClient lobjClient = new SocketClient("192.168.2.2", 5900);
            lobjClient.ReceiveData += new SocketClient.ReceiveDataEventHandler(lobjClient_ReceiveData);

            // Send command '01' + data
            lobjClient.SendData("02", "hijklmn");
            lobjClient.CerrarConexion();
        }

        private static void SendCommand03()
        {
            SocketClient lobjClient = new SocketClient("192.168.2.2", 5900);
            lobjClient.ReceiveData += new SocketClient.ReceiveDataEventHandler(lobjClient_ReceiveData);

            // Send command '01' + data
            lobjClient.SendData("03", "abcdefg");
            lobjClient.CerrarConexion();
        }

        private static void lobjClient_ReceiveData(string pstrCommand, string pstrData)
        {
            if (pstrCommand.Length > 0)
            {
                if (pstrCommand == "FF")
                {
                    Console.WriteLine("Command executed successfully");
                }
                else if (pstrCommand == "F0")
                {
                    Console.WriteLine("Command NOT executed successfully");
                }
            }
        }
    }
}
