// メッセージを送信する。 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()) } }
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 }