Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            var options = new Options();
            var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));

            if (!parser.ParseArguments(args, options))
                Environment.Exit(1);

            using (var context = ZmqContext.Create())
            {
                using (var socket = context.CreateSocket(SocketType.REQ))
                {
                    foreach (var connectEndpoint in options.ConnectEndPoints)
                        socket.Connect(connectEndpoint);

                    long msgCptr = 0;
                    var msgIndex = 0;

                    while (true)
                    {
                        if (msgCptr == long.MaxValue)
                            msgCptr = 0;

                        msgCptr++;
                        if (options.MaxMessage >= 0)
                            if (msgCptr > options.MaxMessage)
                                break;

                        if (msgIndex == options.AlterMessages.Count())
                            msgIndex = 0;

                        var reqMsg = options.AlterMessages[msgIndex++].Replace("#nb#", msgCptr.ToString("d2"));
                        Thread.Sleep(options.Delay);
                        Console.WriteLine("Sending : " + reqMsg);

                        socket.Send(reqMsg, Encoding.UTF8);
                        var replyMsg = socket.Receive(Encoding.UTF8);

                        Console.WriteLine("Received: " + replyMsg + Environment.NewLine);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var options = new Options();
            var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
            if (!parser.ParseArguments(args, options))
                Environment.Exit(1);

            using (var context = ZmqContext.Create())
            {
                using (var socket = context.CreateSocket(SocketType.REQ))
                {
                    foreach (var connectEndpoint in options.connectEndPoints)
                        socket.Connect(connectEndpoint);
                    //long msgCptr = 0;
                    //int msgIndex = 0;
                    string command = string.Empty;

                    do
                    {
                        //if (msgCptr == long.MaxValue)
                        //    msgCptr = 0;
                        //msgCptr++;
                        //if (options.maxMessage >= 0)
                        //    if (msgCptr > options.maxMessage)
                        //        break;
                        //if (msgIndex == options.alterMessages.Count())
                        //    msgIndex = 0;
                        //var reqMsg = options.alterMessages[msgIndex++].Replace("#nb#", msgCptr.ToString("d2"));
                        //Thread.Sleep(options.delay);

                        command = Console.ReadLine();

                        Console.WriteLine("Sending : " + command);
                        socket.Send(command, Encoding.UTF8);
                        var replyMsg = socket.Receive(Encoding.UTF8);
                        Console.WriteLine("Received: " + replyMsg + Environment.NewLine);
                    } while (command != "exit");
                }
            }
        }