Пример #1
0
        static async Task PrintIncomingCodes(string prefix, InterceptConnection connection)
        {
            while (true)
            {
                Code code = await connection.ReceiveCode();

                // If you do not wish to let the received code execute, you can run connection.ResolveCode instead.
                // Before you call either Ignore or Resolve, you may execute as many commands as you want.
                // Codes initiated from the intercepting connection cannot be intercepted from the same connection.
                await connection.IgnoreCode();

                Console.WriteLine($"[{prefix}] {code.Channel}: {code}");
            }
        }
Пример #2
0
        private static async Task PrintIncomingCodes(InterceptConnection connection)
        {
            try
            {
                Code code;
                do
                {
                    code = await connection.ReceiveCode();

                    // If you do not wish to let the received code execute, you can run connection.ResolveCode instead.
                    // Before you call one of Cancel, Ignore, or Resolve you may execute as many commands as you want.
                    // Codes initiated from the intercepting connection cannot be intercepted from the same connection.
                    await connection.IgnoreCode();

                    Console.WriteLine($"[{connection.Mode}] {code.Channel}: {code}");
                }while (true);
            }
            catch (SocketException)
            {
                // Server has closed the connection
            }
        }