示例#1
0
        /// <summary>基础测试</summary>
        public static void TestBase()
        {
            var svr = new MQServer();

            svr.Start();

            var client = new MQClient();

            client.Name = "user1";
            client.Public("test");

            var user = new MQClient();

            user.Name      = "user2";
            user.Received += (s, e) =>
            {
                XTrace.WriteLine("user.收到推送 {0}", e.Arg);
            };
            //user.Open();
            user.Subscribe("test");

            for (int i = 0; i < 3; i++)
            {
                client.Send("test", "测试{0}".F(i + 1));
            }

            Console.ReadKey(true);

            client.Dispose();
            user.Dispose();
            svr.Dispose();
        }
示例#2
0
文件: MQTest.cs 项目: stylinlin/X
        /// <summary>基础测试</summary>
        public static async void TestBase()
        {
            var svr = new MQServer();

            //svr.Server.Log = XTrace.Log;
            svr.Start();

            var client = new MQClient();

            client.Log  = XTrace.Log;
            client.Name = "张三";
            await client.Login();

            await client.CreateTopic("新生命团队");

            var user = new MQClient();

            user.Log  = XTrace.Log;
            user.Name = "李四";
            await user.Login();

            //user.Received += (s, e) =>
            //{
            //    XTrace.WriteLine("user.收到推送 {0}", e.Arg);
            //};
            await user.Subscribe("新生命团队");

            for (int i = 0; i < 3; i++)
            {
                await client.Public("测试{0}".F(i + 1));
            }

            Console.ReadKey(true);

            client.Dispose();
            user.Dispose();
            svr.Dispose();
        }