コード例 #1
0
ファイル: mqtt-bench.go プロジェクト: EriclLee/mqtt-bench
// メッセージを送信する。
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())
	}
}
コード例 #2
0
ファイル: mqtt.go プロジェクト: kyokomi-sandbox/sandbox
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
}