Exemple #1
0
/**
 * The MQTT server. Listens for and handles requests between
 * publishers and subsribers.
 */
func serve() {
	l, err := net.Listen("tcp", ":4000")
	if err != nil {
		die(err)
	}
	svr := mqtt.NewServer(l)
	svr.Start()
	<-svr.Done
}
Exemple #2
0
//Run the broker
func (b *MqttBroker) Run() {

	l, err := net.Listen("tcp", b.port)
	gotError(err)

	svr := mqtt.NewServer(l)
	svr.Start()
	<-svr.Done
}
Exemple #3
0
// Start the MQTT server.
func (w *MQTTServer) Run() {
	port := getInputOrConfig(w.Port, "MQTT_PORT")
	listener, err := net.Listen("tcp", port)
	flow.Check(err)
	glog.Infoln("mqtt started, port", port)
	server := mqtt.NewServer(listener)
	server.Start()
	w.PortOut.Send(port)
	<-server.Done
	glog.Infoln("mqtt done, port", port)
}
Exemple #4
0
func main() {
	flag.Parse()

	l, err := net.Listen("tcp", *addr)
	if err != nil {
		log.Print("listen: ", err)
		return
	}
	svr := mqtt.NewServer(l)
	svr.Start()
	<-svr.Done
}
Exemple #5
0
func main() {
	cfg := &tls.Config{
		Certificates: readCert(),
		NextProtos:   []string{"mqtt"},
	}
	l, err := tls.Listen("tcp", ":8883", cfg)
	if err != nil {
		log.Print("listen: ", err)
		return
	}
	svr := mqtt.NewServer(l)
	svr.Start()
	<-svr.Done
}
Exemple #6
0
func main() {
	// see godoc net/http/pprof
	go func() {
		log.Println(http.ListenAndServe("localhost:6060", nil))
	}()

	l, err := net.Listen("tcp", ":1883")
	if err != nil {
		log.Print("listen: ", err)
		return
	}
	svr := mqtt.NewServer(l)
	svr.Start()
	<-svr.Done
}