diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-01-03 06:54:13 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-01-03 06:54:13 +0300 |
commit | f4e4692a94b24f661d67cd4e98ac9b2ca9928c0f (patch) | |
tree | b9c917fc783b6bdd15fa2781b607b34b3cf51606 /xmpp/handlers.go | |
parent | 462a537021f471579877eceb1dd6c47154d8052d (diff) |
Multiple resources handling
Diffstat (limited to 'xmpp/handlers.go')
-rw-r--r-- | xmpp/handlers.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/xmpp/handlers.go b/xmpp/handlers.go index ee767ad..59d4c62 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -85,7 +85,7 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) { }).Error(errors.Wrap(err, "Invalid to JID!")) } else if toID == gateway.Jid.Bare() { if strings.HasPrefix(msg.Body, "/") { - response := session.ProcessTransportCommand(msg.Body) + response := session.ProcessTransportCommand(msg.Body, fromJid.Resource) if response != "" { gateway.SendMessage(msg.From, "", response, component) } @@ -169,17 +169,18 @@ func handlePresence(s xmpp.Sender, p stanza.Presence) { switch p.Type { // destroy session case "unsubscribed", "unsubscribe": - session.Disconnect() - delete(sessions, bareFromJid) + if session.Disconnect(fromJid.Resource, false) { + delete(sessions, bareFromJid) + } // go offline case "unavailable", "error": - session.Disconnect() + session.Disconnect(fromJid.Resource, false) // go online case "probe", "", "online": // due to the weird implementation of go-tdlib wrapper, it won't // return the client instance until successful authorization go func() { - err = session.Connect() + err = session.Connect(fromJid.Resource) if err != nil { log.Error(errors.Wrap(err, "TDlib connection failure")) } else { |