﻿    // -- Test request for server

    ClientKey = New UUID;
    Message   = "Test data sending to the server";

    ClientParams = New Array;
    ClientParams.Add("127.0.0.1:7788"); // Our server
    ClientParams.Add(Message); // Test string
    ClientParams.Add("UTF-8"); // Encoding
    ClientParams.Add("20000"); // Timeout, for make it in time launch server

    // Sending a test request via TCP client methods
    ClientBackground = BackgroundJobs.Execute("OPI_TCP.SendLine", ClientParams, ClientKey);

    // --

    TCPServer = OPI_TCP.CreateServer(7788, True);

    NewConnection = OPI_TCP.WaitIncomingConnections(TCPServer, 20);

    If NewConnection["result"] Then

        Connection = NewConnection["connection"]["id"];

        ProcessingParameterArray = New Array;
        ProcessingParameterArray.Add(Connection); // String: "1:7788"

        BackgroundProcessing = BackgroundJobs.Execute("OPI_Tests.TCP_ProcessConnection", ProcessingParameterArray);

        TCP_ProcessConnection(Connection);

    EndIf;

    Shutdown = OPI_TCP.StopServer(TCPServer);
