Пример #1
0
        public override void Start(Options options)
        {
            Logger.LogInformation($"Starting [{options.Id}]");

            using (var socket = Context.CreatePullSocket())
            {
                socket.Bind(options.Address());

                while (true)
                {
                    // read a message
                    var message = socket.ReceiveFrameString();
                    Logger.LogDebug($"[{options.Id}] Received - {message}");
                }
            }
        }
Пример #2
0
        public override void Start(Options options)
        {
            Logger.LogInformation($"Starting [{options.Id}]");

            using (var socket = Context.CreatePullSocket())
            {
                socket.Bind(options.Address());

                while (true)
                {
                    // read a message
                    var message = socket.ReceiveFrameString();
                    Logger.LogDebug($"[{options.Id}] Received - {message}");
                }
            }
        }
Пример #3
0
        public override void Start(Options options)
        {
            Logger.LogInformation($"Starting [{options.Id}]");

            using (var socket = Context.CreateSubscriberSocket())
            {
                socket.Connect(options.Address());
                socket.Subscribe(options.Topic); // if empty subscribes to all

                while (true)
                {
                    // read a message
                    var message = socket.ReceiveFrameString();
                    Logger.LogDebug($"[{options.Id}] Received - {message}");
                }
            }
        }
Пример #4
0
        public override void Start(Options options)
        {
            Logger.LogInformation($"Starting [{options.Id}]");

            using (var socket = Context.CreateSubscriberSocket())
            {
                socket.Connect(options.Address());
                socket.Subscribe(options.Topic); // if empty subscribes to all

                while (true)
                {
                    // read a message
                    var message = socket.ReceiveFrameString();
                    Logger.LogDebug($"[{options.Id}] Received - {message}");
                }
            }
        }
Пример #5
0
        public override void Start(Options options)
        {
            Logger.LogInformation($"Starting [{options.Id}]");

            using (var socket = Context.CreatePushSocket())
            {
                socket.Connect(options.Address());

                var sw = Stopwatch.StartNew();

                for (var i = 0; i < options.Messages; i++)
                {
                    // write a message
                    socket.SendFrame($"Message: [{options.Id}] - {i}");
                }

                Logger.LogInformation($" [{options.Id}] - Sent {options.Messages} messages in: {sw.ElapsedMilliseconds} milliseconds");
            }
        }
Пример #6
0
        public override void Start(Options options)
        {
            Logger.LogInformation($"Starting [{options.Id}]");

            using (var socket = Context.CreateResponseSocket())
            {
                socket.Bind(options.Address());

                while (true)
                {
                    // read a message
                    var message = socket.ReceiveFrameString();
                    Logger.LogDebug($"[{options.Id}] Received - {message}");

                    // reply with a response
                    socket.SendFrame($"Thanks for {message} from {options.Id}");
                }
            }
        }
Пример #7
0
        public override void Start(Options options)
        {
            Logger.LogInformation($"Starting [{options.Id}]");

            using (var socket = Context.CreatePushSocket())
            {
                socket.Connect(options.Address());

                var sw = Stopwatch.StartNew();

                for (var i = 0; i < options.Messages; i++)
                {
                    // write a message
                    socket.SendFrame($"Message: [{options.Id}] - {i}");
                }

                Logger.LogInformation($" [{options.Id}] - Sent {options.Messages} messages in: {sw.ElapsedMilliseconds} milliseconds");
            }
        }
Пример #8
0
        public override void Start(Options options)
        {
            Logger.LogInformation($"Starting [{options.Id}]");

            using (var socket = Context.CreateResponseSocket())
            {
                socket.Bind(options.Address());

                while (true)
                {
                    // read a message
                    var message = socket.ReceiveFrameString();
                    Logger.LogDebug($"[{options.Id}] Received - {message}");

                    // reply with a response
                    socket.SendFrame($"Thanks for {message} from {options.Id}");
                }
            }
        }
Пример #9
0
        public override void Start(Options options)
        {
            Logger.LogInformation($"Starting [{options.Id}]");

            using (var socket = Context.CreatePublisherSocket())
            {
                socket.Bind(options.Address());

                var sw = Stopwatch.StartNew();

                var i = 0;
                while (true)
                {
                    // write some messages
                    socket.SendFrame($"Message A: [{options.Id}] - {i}");
                    socket.SendFrame($"Message B: [{options.Id}] - {i}");
                    i++;
                    Thread.Sleep(100);
                }
            }
        }
Пример #10
0
        public override void Start(Options options)
        {
            Logger.LogInformation($"Starting [{options.Id}]");

            using (var socket = Context.CreatePublisherSocket())
            {
                socket.Bind(options.Address());

                var sw = Stopwatch.StartNew();

                var i = 0;
                while(true)
                {
                    // write some messages
                    socket.SendFrame($"Message A: [{options.Id}] - {i}");
                    socket.SendFrame($"Message B: [{options.Id}] - {i}");
                    i++;
                    Thread.Sleep(100);
                }
            }
        }