add mqtt listenner
This commit is contained in:
parent
2624897efe
commit
db518b5c19
4 changed files with 133 additions and 0 deletions
|
@ -41,6 +41,7 @@ type Server struct {
|
|||
unixListener net.Listener
|
||||
smtpServer *smtp.Server
|
||||
smtpServerBackend *smtpBackend
|
||||
mqttServerBackend *mqttBackend
|
||||
smtpSender mailer
|
||||
topics map[string]*topic
|
||||
visitors map[netip.Addr]*visitor
|
||||
|
@ -228,6 +229,11 @@ func (s *Server) Run() error {
|
|||
errChan <- s.runSMTPServer()
|
||||
}()
|
||||
}
|
||||
if s.config.MqttServer != "" {
|
||||
go func() {
|
||||
s.runMqttServer()
|
||||
}()
|
||||
}
|
||||
s.mu.Unlock()
|
||||
go s.runManager()
|
||||
go s.runDelayedSender()
|
||||
|
@ -1221,6 +1227,13 @@ func (s *Server) runSMTPServer() error {
|
|||
return s.smtpServer.ListenAndServe()
|
||||
}
|
||||
|
||||
func (s *Server) runMqttServer() {
|
||||
s.mqttServerBackend = newMqttBackend(s.config, s.handle)
|
||||
s.mqttServerBackend.Connect()
|
||||
s.mqttServerBackend.Subscribe()
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Server) runManager() {
|
||||
for {
|
||||
select {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue