Esempio n. 1
0
// メッセージを送信する。
func Publish(client *MQTT.MqttClient, topic string, qos byte, retain bool, message string) {
	token := client.Publish(topic, qos, retain, message)

	if token.Wait() && token.Error() != nil {
		fmt.Printf("Publish error: %s\n", token.Error())
	}
}
Esempio n. 2
0
func Publish(client *MQTT.MqttClient, topic, message string) error {
	topicName := config.user + "/" + topic
	qos := 0

	receipt := client.Publish(MQTT.QoS(qos), topicName, message)
	<-receipt // Publish成功を待ち受ける

	return nil
}