예제 #1
0
파일: Demo.cs 프로젝트: HTD/Woof.Console
    static void Main()
    {
        Console.SetOut(new HexColor());
        ConsoleEx.AssemblyHeader(useColor: true);
        Console.WriteLine("Testing `066`Woof.Console`:");
        Console.WriteLine();
        var tasksCount = TasksLeft = 8;

        for (int i = 0; i < tasksCount; i++)
        {
            lock (L1) {
                Console.Write($"Starting test task #{i + 1}...");
                var progress = new ConsoleProgress();
                Task.Run(async() => await TestTask(progress));
                Task.Delay(1).Wait();
            }
        }
        Semaphore.Wait();
        Console.WriteLine();
        using var hexDump = new HexDump { Format = HexDump.Formats.HexColor };
        var testData = new byte[48];

        PRNG.NextBytes(testData);
        hexDump.Write(testData);
        Console.WriteLine();
        var delayFilter = new Delay();

        Console.SetOut(delayFilter);
        Console.WriteLine("Testing `0ff`Delay` filter..............`070`OK!`");
        Console.SetOut(delayFilter.Out); // remove the delay filter.
        Console.WriteLine();
        ConsoleEx.WaitForCtrlC("All test completed successfully, press Ctrl+C to exit...");
    }
예제 #2
0
        internal void UDPSendFrame(LoginResponse auth, byte[] frame, string ipAddress, int port, bool isDebugMode)
        {
            UdpClient udpClient = new UdpClient(ipAddress, port);

            if (isDebugMode)
            {
                ConsoleOutput.WriteLine(HexDump.Write(frame), ConsoleColor.White);
            }

            try
            {
                udpClient.Send(frame, frame.Length);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }