Ejemplo n.º 1
0
 private void CreateMQTTService()
 {
     Logger.LogInfo("创建MQTT对象开始");
     if (Helper.GetAppConfig("Enable") == "true")
     {
         try
         {
             Logger.LogInfo("创建预发布环境MQTT对象");
             address           = Helper.GetAppConfig("address");
             dataCenterAddress = Helper.GetAppConfig("dataCenterAddress");
             mqttAddress       = Helper.GetAppConfig("mqttHost");
             ssoAddress        = Helper.GetAppConfig("ssoHost");
             string port = Helper.GetAppConfig("mqttPort");
             m_mqttService = new MQTTService(mqttAddress, port);
             release       = true;
         }
         catch (Exception ex)
         {
             Logger.LogError("创建MQTT对象失败, " + ex.Message);
         }
     }
     else
     {
         if (CreateMQTTService("Service_test"))
         {
             Logger.LogInfo("创建测试环境MQTT对象");
         }
         else if (CreateMQTTService("Service_deve"))
         {
             Logger.LogInfo("创建开发环境MQTT对象");
         }
     }
     Logger.LogInfo("创建MQTT对象结束");
 }
Ejemplo n.º 2
0
        //public void SetMCallBack(string name)
        //{
        //    m_callBackService.ClientName = name;
        //    m_callBackService.MessageReceived += new MessageReceivedHandler(cb_MessageReceived);
        //}

        ///// <summary>
        ///// 进程间通信服务
        ///// </summary>
        //public InterProcessService MCallBack
        //{
        //    get { return m_callBackService; }
        //}

        private void CreateMQTTService()
        {
            if (Helper.GetAppConfig("Enable") == "true")
            {
                try
                {
                    address     = Helper.GetAppConfig("address");
                    mqttAddress = Helper.GetAppConfig("mqttHost");
                    ssoAddress  = Helper.GetAppConfig("ssoHost");
                    string port = Helper.GetAppConfig("mqttPort");
                    m_mqttService = new MQTTService(mqttAddress, port);
                    release       = true;
                }
                catch (Exception ex)
                {
                    string text = "Create MQTTService object failed, " + ex.Message;
                    throw new ApplicationException(text, ex);
                }
            }
            else
            {
                CreateMQTTService("Service_test");
                CreateMQTTService("Service_deve");
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 集合Service创建MQTTBussiness服务
 /// </summary>
 private void CreateMQTTService(string name)
 {
     try
     {
         if (Helper.GetConfig(name, "enable") == "true" && m_mqttService == null)
         {
             string cname = Helper.GetConfig(name, "name");
             mqttAddress = Helper.GetConfig(name, "addressQuote");
             ssoAddress  = Helper.GetConfig(name, "ssoAddressQuote");
             string port = Helper.GetConfig(name, "MQTTPort");
             m_mqttService = new MQTTService(mqttAddress, port);
         }
     }
     catch (Exception ex)
     {
         string text = "Create MQTTService object failed, " + ex.Message;
         throw new ApplicationException(text, ex);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 集合Service创建MQTTBussiness服务
 /// </summary>
 private bool CreateMQTTService(string name)
 {
     try
     {
         if (Helper.GetConfig(name, "enable") == "true" && m_mqttService == null)
         {
             string cname = Helper.GetConfig(name, "name");
             address           = mqttAddress = Helper.GetConfig(name, "addressQuote");
             dataCenterAddress = Helper.GetConfig(name, "dataCenterAddress");
             ssoAddress        = Helper.GetConfig(name, "ssoAddressQuote");
             string port = Helper.GetConfig(name, "MQTTPort");
             m_mqttService = new MQTTService(mqttAddress, port);
             return(true);
         }
     }
     catch (Exception ex)
     {
         Logger.LogError("创建MQTT对象失败, " + ex.Message);
     }
     return(false);
 }