using System.Collections.Generic; using Blue; using UnityEngine; using uPLibrary.Networking.M2Mqtt.Messages; public class MQTTTest : AbstractController { private List topics = new List() { "client/manage", "client/mqttx_d4c106a3", "client/mqttx_b4c02ddc", "client/mqttx_ab869d21" }; private string[] topicSub = new string[4] { "client/manage", "client/mqttx_d4c106a3", "client/mqttx_b4c02ddc", "client/mqttx_ab869d21" }; private IMQTTService mQTTService; private void Start() { mQTTService = this.GetService(); } void Update() { if(Input.GetKeyDown(KeyCode.A)) { mQTTService.SubscribeTopics(topicSub, new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE , MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE , MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE }); } else if(Input.GetKeyDown(KeyCode.S)) { mQTTService.UnsubscribeTopics(topicSub); } if(Input.GetKeyDown(KeyCode.D)) { mQTTService.Connect(); } if(Input.GetKeyDown(KeyCode.Q)) { this.SendCommand(new MQTTCommand(topics[0],"KeyCode.Q")); } else if(Input.GetKeyDown(KeyCode.W)) { this.SendCommand(new MQTTCommand(topics[1],"KeyCode.W")); } else if(Input.GetKeyDown(KeyCode.E)) { this.SendCommand(new MQTTCommand(topics[2],"KeyCode.E")); } else if(Input.GetKeyDown(KeyCode.R)) { this.SendCommand(new MQTTCommand(topics[3],"KeyCode.R")); } } }