Example #1
0
 public Message(PublishArrivedArgs e)
 {
     datetime = DateTime.Now;
     topic    = e.Topic;
     payload  = e.Payload.ToString();
     name     = StaticResources.QosToName(e.QualityOfService);
     retained = e.Retained ? "是" : "否";
 }
Example #2
0
        private void SetCombobox()
        {
            foreach (string name in StaticResources.GetNameEnumerable())
            {
                comboBoxWillQos.Items.Add(name);
            }

            comboBoxWillQos.SelectedIndex = 0;
            this.Focus();
        }
Example #3
0
 public void Reset(int time, string t, DataTable dataTable, string qosName, bool retain)
 {
     timeInterval     = time;
     topic            = t;
     dataTableMessage = dataTable;
     mqttClient       = MqttClient.Instance();
     qoS                 = StaticResources.NameToQos(qosName);
     retained            = retain;
     thread              = new System.Threading.Thread(AutoPublish);
     thread.IsBackground = true;
 }
Example #4
0
        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("任务名:" + TaskName + "\r\n");
            stringBuilder.Append("运行状态:" + (state ? "运行中" : "停止") + "\r\n");
            stringBuilder.Append("推送主题:" + topic + "\r\n");
            stringBuilder.Append("服务质量:" + StaticResources.QosToName(qoS));
            stringBuilder.Append("是否保留:" + (retained ? "是" : "否") + "\r\n");
            return(stringBuilder.ToString());
        }
Example #5
0
 private void InitComboBox()
 {
     comboBoxValueType.Items.Add(typeof(string));
     comboBoxValueType.Items.Add(typeof(int));
     comboBoxValueType.Items.Add(typeof(float));
     comboBoxValueType.SelectedIndex = 0;
     foreach (string name in StaticResources.GetNameEnumerable())
     {
         comboBoxPubQos.Items.Add(name);
     }
     comboBoxPubQos.SelectedIndex = 0;
     this.Focus();
 }
Example #6
0
 public bool SetWill(string topic, string message, string qos, bool retained)
 {
     if (mqtt == null || mqtt.IsConnected == false)
     {
         withWill     = true;
         willTopic    = topic;
         willMessage  = message;
         willQos      = StaticResources.NameToQos(qos);
         willRetained = retained;
         return(true);
     }
     return(false);
 }
Example #7
0
 public void Publish(string topic, string message, string name, bool retained)
 {
     Publish(topic, message, StaticResources.NameToQos(name), retained);
 }
Example #8
0
 public void Subscribe(string topic, string name)
 {
     StaticResources.messageQueue.Enqueue("时间:" + DateTime.Now.ToString() +
                                          "订阅信息,信息ID为:" +
                                          mqtt.Subscribe(topic, StaticResources.NameToQos(name)));
 }