예제 #1
0
        /// <summary>
        /// 订阅消息
        /// </summary>
        private void ThreadSubscriber()
        {
            using (SubscriberSocket subscriberSocket = new SubscriberSocket())
            {
                subscriberSocket.Subscribe("StartCenterServer");
                subscriberSocket.Subscribe("CloseCenterServer");

                subscriberSocket.Subscribe("ServerParameterPushNew");
                subscriberSocket.Subscribe("RaceInfoPushNew");
                subscriberSocket.Subscribe("PushNewHorseInfo");

                subscriberSocket.Subscribe("PushNewQQPDiscountsBetAndEat");
                subscriberSocket.Subscribe("PushNewWWPDiscountsBetAndEat");
                subscriberSocket.Subscribe("PushNewAllDiscountsBetOnly");

                subscriberSocket.Subscribe("PushNewOdds");

                subscriberSocket.Connect(MQConfig.PublishServer);
                while (!PublicData.CancellationToken.IsCancellationRequested)
                {
                    try
                    {
                        KeyData kd = subscriberSocket.SubscriberReceive();
                        Task.Factory.StartNew(() => HandleKeyData_Subscriber(kd.Key, kd.DataString));
                    }
                    catch (Exception ex)
                    {
                        LogUtil.Error($"订阅消息执行异常:{ex.Message}");
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 订阅消息
        /// </summary>
        private void ThreadSubscriber()
        {
            using (SubscriberSocket subscriberSocket = new SubscriberSocket())
            {
                subscriberSocket.Subscribe("StartCenterServer");
                subscriberSocket.Subscribe("CloseCenterServer");
                subscriberSocket.Subscribe("ServerParameterPushNew");
                subscriberSocket.Subscribe("RaceInfoPushNew");

                subscriberSocket.Connect(MQConfig.PublishServer);
                while (!PublicData.CancellationToken.IsCancellationRequested)
                {
                    try
                    {
                        KeyData kd = subscriberSocket.SubscriberReceive();
                        HandleKeyData_Subscriber(kd.Key, kd.DataString);
                    }
                    catch (Exception ex)
                    {
                        LogUtil.Error($"订阅消息执行异常:{ex.Message}");
                    }
                }
            }
        }