Beispiel #1
0
        static void Main(string[] args)
        {
            NetComClient client = new NetComClient("127.0.0.1", 2225);

            client.Debug         = NetComDebugOutput.ToConsole;
            client.EncodeMessage = NetComMessageEncoder.Default;
            client.ParseMessage  = NetComMessageParser.Default;
            client.LibraryExec   = NetComLibraryExecuter.Default;

            client.Init();
            client.Start();
            client.EnableListening();
            client.EnableProcessing();
            client.EnableSending();

            int i = 0;

            while (i < 100)
            {
                client.SendToServer("[Reply:ReplyValue];[Reply2:ReplyValue2]");
                //server.Broadcast("[[UI i is brotkastl]]");

                Thread.Sleep(5000);
            }

            Console.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            #region ========= SETTING UP THE CLIENT =========

            // Set the server-IP
            // If your server and client are running on the same machine, use '127.0.0.1'
            // If you need to resolve an URL, use 'Dns.GetHostAddresses("your.sample-url.com")[0].ToString()'
            string serverIP = "212.169.76.12";

            // Set the TCP-Port on which the server is hosted
            int tcpServerPort = 2225;

            // Create a instance of the server
            NetComClient client = new NetComClient(serverIP, tcpServerPort);

            // Enter the username and password of the client.
            // In case the authentication fails, the instructions won't get
            // processed on the server.
            client.Login("SampleUsername", "SamplePassword");

            // Set the wanted Debug-Output
            // Pre-Defined debug-outputs can be found
            // in the DebugOutput-Class
            client.SetDebugOutput(DebugOutput.ToConsole);

            // Start the client and all its background-processes.
            client.Start();

            #endregion

            #region ========= COMMUNICATE WITH CLIENTS =========

            // Create the instruction that should be sent.
            // Since the only receiver a client can address is the server, the receiver-parameter is always 'null'
            var instruction = new InstructionLibraryEssentials.SimpleMessageBox(client, null, "Hello world!");

            // As soon as server.Send(...) gets called, the instruction is queued for sending and gets
            // sent out as soon as the instruction-preprocessing is done.
            client.Send(instruction);

            #endregion
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Type t = Type.GetType(typeof(NetComInstructionLib.PlainText).AssemblyQualifiedName);

            Console.WriteLine();

            NetComClient client = new NetComClient("127.0.0.1", 2225, "TobiHatti", "Apfel123");

            client.Debug         = NetComDebugOutput.ToConsole;
            client.ParseMessage  = NetComMessageParser.DefaultClient;
            client.EncodeMessage = NetComMessageEncoder.DefaultClient;

            client.Start();

            int i = 0;

            while (true)
            {
                client.SendRSA(new NCILib.PlainText(client, $"Hallo i bin a test-Message N° {i++}"));
                Thread.Sleep(2000);
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            var clientNr = "0";

            try
            {
                clientNr = args[0];
            }
            catch
            {
            }

            Console.Title           = $"Client {clientNr}";
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("===================================");
            Console.WriteLine($"=           C L I E N T - {clientNr}       =");
            Console.WriteLine("===================================\r\n");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(Dns.GetHostAddresses("endev.ddns.net")[0].ToString());

            //NetComClient client = new NetComClient(Dns.GetHostAddresses("endev.ddns.net")[0].ToString(), 2225);
            ClientHandler clientHandler = new ClientHandler("127.0.0.1", 2225);



            Console.Write("Username: "******"Password: "******"Tobias", "1");

            clientHandler.SetDebugOutput(DebugOutput.ToConsole);

            clientHandler.Start();

            Thread.Sleep(3000);

            NetComClient client = clientHandler.GetClient();

            client.Send(new InstructionLibraryEssentials.TestSample(client, null));
            while (true)
            {
                // Clients can only send directly to the server, so the receiver is set to null

                Console.Title = $"Client {clientNr}  -  Send: {clientHandler.HandlerData.LogSendCounter}     Receive: {clientHandler.HandlerData.LogReceiveCounter}";
                client.Send(new InstructionLibraryEssentials.TestSample(client, null));

                //client.Send(new InstructionLibraryEssentials.RichMessageBox(client, null, "Hallo", "Titel", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Hand));

                //client.Send(new InstructionLibraryEssentials.ToOutputStream(client, null, "Hallo"));


                Thread.Sleep(new Random().Next(500, 1000));
            }

#pragma warning disable 0162 // unreachable code
            Console.WriteLine("Done.");

            Console.ReadKey();
#pragma warning restore 0162 // unreachable code
        }