reaftor: mtp interface + mqtt disconnection log

This commit is contained in:
leandrofars 2024-02-05 23:29:45 -03:00
parent ef34e499de
commit d9560ec167
2 changed files with 5 additions and 11 deletions

View File

@ -86,6 +86,7 @@ func (m *Mqtt) Connect() {
}
func (m *Mqtt) Disconnect() {
log.Println("Disconnecting from MQTT broker...")
err := c.Disconnect(m.Ctx)
if err != nil {
log.Fatalf("failed to send Disconnect: %s", err)

View File

@ -23,7 +23,7 @@ type Broker interface {
//Request(msg []byte, msgType usp_msg.Header_MsgType, pubTopic string, subTopic string)
}
// Not used, since we are using a broker solution.
// Not used, since we are using a broker approach.
type P2P interface {
}
@ -31,14 +31,7 @@ type P2P interface {
func MtpService(b Broker, done chan os.Signal, wg *sync.WaitGroup) {
b.Connect()
wg.Done()
go func() {
for range done {
b.Disconnect()
log.Println("Successfully disconnected to MTPs!")
// Receives signal and then replicates it to the rest of the app.
done <- os.Interrupt
}
}()
//b.Subscribe()
<-done
log.Println("Disconnect of MTP!")
b.Disconnect()
}