void MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) { string[] topics = e.Topic.Split('/'); if (!Enum.IsDefined(typeof(MQTTMsgType), topics[1])) { Debug.Log("Received message from different topic: " + e.Topic); return; } MQTTMsgType topic = (MQTTMsgType)Enum.Parse(typeof(MQTTMsgType), topics[1]); switch (topic) { case MQTTMsgType.Event: ActionPerformed(e); break; case MQTTMsgType.Interface: InterfaceReceived(e); break; case MQTTMsgType.State: StateReceived(e); break; case MQTTMsgType.ConnectReq: ConnectReqReceived(e); break; } }
public void MqttPublishMsg(MQTTMsgType type, MQTTMsgEnvironment area, string RPI, string device, string msg) { string topic = "FtRD/"; if (type == MQTTMsgType.ALL) { topic += "#"; } else { topic += type.ToString() + "/"; if (area == MQTTMsgEnvironment.ALL) { topic += "#"; } else { topic += area.ToString() + "/"; if (RPI == AllTopicLabel) { topic += AllTopicLabel; } else { topic += RPI + "/"; if (device == AllTopicLabel) { topic += AllTopicLabel; } else { topic += device; } } } } Debug.Log("Topic to publish to: " + topic + " : [" + msg + "]"); Byte[] bytes = System.Text.Encoding.UTF8.GetBytes(msg); client.Publish(topic, bytes); }
internal void MqttPublishMsg(MQTTMsgType action, MQTTMsgEnvironment house, object rPI, object iD, string v) { throw new NotImplementedException(); }