1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-05-14 19:29:11 +08:00
Drasko DRASKOVIC a79a9012e4 Add coap support
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
2017-10-01 16:38:32 +02:00

28 lines
464 B
Go

// Package nats contains NATS-specific message repository implementation.
package nats
import (
"encoding/json"
"github.com/mainflux/mainflux/writer"
broker "github.com/nats-io/go-nats"
)
const topic string = "msg.coap"
// Stored NATS connection
var snc *broker.Conn
func StoreConnection(nc *broker.Conn) {
snc = nc
}
func Send(msg writer.RawMessage) error {
b, err := json.Marshal(msg)
if err != nil {
return err
}
return snc.Publish(topic, b)
}