From c6090c0d375f28002166a463cfc7b7cda4425626 Mon Sep 17 00:00:00 2001 From: xengineering Date: Mon, 15 May 2023 19:07:56 +0200 Subject: Move disconnect announcement closer to connect This keeps the two strongly related actions to one block of code which improves readability and might avoid some bugs. --- xmpp.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xmpp.go b/xmpp.go index ae38682..c432a62 100644 --- a/xmpp.go +++ b/xmpp.go @@ -16,8 +16,6 @@ const ( ) func xmpp(rxChan chan GuiEvent, txChan chan any, jid string, pwd string) { - defer func() { txChan <- XmppDisconnect }() - conn, err := setupConn(jid) if err != nil { log.Print(err) @@ -39,6 +37,7 @@ func xmpp(rxChan chan GuiEvent, txChan chan any, jid string, pwd string) { defer sendStreamEnd(enc, dbg, end) txChan <- XmppConnect + defer func() { txChan <- XmppDisconnect }() for { select { -- cgit v1.2.3-70-g09d2