Exemple #1
0
        static void Main(string[] args)
        {
            using (var pubSocket = new PublisherSocket())
            {
                // 미해결 메시지 제한
                pubSocket.Options.SendHighWatermark = 1000;

                // 바인딩
                pubSocket.Bind("tcp://*:12345");

                for (var i = 0; i < 100; i++)
                {
                    if (i % 2 == 0)
                    {
                        var msg = "TopicA msg-" + i + " 노석수 바보";
                        Console.WriteLine($"Sending message : {msg}");
                        pubSocket.SendMoreFrame("TopicA").SendFrame(msg);
                    }
                    else
                    {
                        var msg = "TopicB msg-" + i + " 노석수 천재";
                        Console.WriteLine($"Sending message : {msg}");
                        pubSocket.SendMoreFrame("TopicB").SendFrame(msg);
                    }

                    Thread.Sleep(1000);
                }
            }
        }
        static void Main(string[] args)
        {
            Random rand = new Random(50);

            using (var pubSocket = new PublisherSocket())
            {
                Console.WriteLine("Publisher socket binding...");
                pubSocket.Options.SendHighWatermark = 1000;
                pubSocket.Bind("tcp://localhost:12345");

                for (var i = 0; i < 100; i++)
                {
                    var randomizedTopic = rand.NextDouble();
                    if (randomizedTopic > 0.5)
                    {
                        var msg = "TopicA msg-" + i;
                        Console.WriteLine("Sending message : {0}", msg);
                        pubSocket.SendMoreFrame("TopicA").SendFrame(msg);
                    }
                    else
                    {
                        var msg = "TopicB msg-" + i;
                        Console.WriteLine("Sending message : {0}", msg);
                        pubSocket.SendMoreFrame("TopicB").SendFrame(msg);
                    }

                    Thread.Sleep(500);
                }
            }
        }
 static void new_thread(string new_command, byte[] volume, PublisherSocket pubSocket)
 {
     pubSocket.SendMoreFrame(new_command).SendFrame(volume);
 }