コード例 #1
0
ファイル: StaticResources.cs プロジェクト: wwkkww1983/MQTT-
 public Message(PublishArrivedArgs e)
 {
     datetime = DateTime.Now;
     topic    = e.Topic;
     payload  = e.Payload.ToString();
     name     = StaticResources.QosToName(e.QualityOfService);
     retained = e.Retained ? "是" : "否";
 }
コード例 #2
0
ファイル: ConectWindow.xaml.cs プロジェクト: wwkkww1983/MQTT-
        private void SetCombobox()
        {
            foreach (string name in StaticResources.GetNameEnumerable())
            {
                comboBoxWillQos.Items.Add(name);
            }

            comboBoxWillQos.SelectedIndex = 0;
            this.Focus();
        }
コード例 #3
0
ファイル: MqttClient.cs プロジェクト: wwkkww1983/MQTT-
 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;
 }
コード例 #4
0
ファイル: MqttClient.cs プロジェクト: wwkkww1983/MQTT-
        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());
        }
コード例 #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();
 }
コード例 #6
0
ファイル: MqttClient.cs プロジェクト: wwkkww1983/MQTT-
 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);
 }
コード例 #7
0
ファイル: MqttClient.cs プロジェクト: wwkkww1983/MQTT-
 public void Publish(string topic, string message, string name, bool retained)
 {
     Publish(topic, message, StaticResources.NameToQos(name), retained);
 }
コード例 #8
0
ファイル: MqttClient.cs プロジェクト: wwkkww1983/MQTT-
 public void Subscribe(string topic, string name)
 {
     StaticResources.messageQueue.Enqueue("时间:" + DateTime.Now.ToString() +
                                          "订阅信息,信息ID为:" +
                                          mqtt.Subscribe(topic, StaticResources.NameToQos(name)));
 }