public virtual int PostEvent(CLEvent e) { if (!IsConnected || mqttClient == null) { return -1; } string topic = TopicFromEvent(e); string message = e.serialize(); int returnCode = mqttClient.Publish(topic, Encoding.UTF8.GetBytes(message)); return returnCode; }
public int PostEvent(CLEvent e) { if (listenerThread == null) { return 1; } string topic = TopicFromEventType(e.EventType); string message = e.serialize(); try { NetduinoMQTT.PublishMQTT(socket, topic, message); } catch { Disconnect(); Connect(host, userName, password, port); } // do not log publish here with mqtt logger, it causes a call cycle return 0; }