aboutsummaryrefslogtreecommitdiff
path: root/xmpp
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-01-03 06:54:13 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-01-03 06:54:13 +0300
commitf4e4692a94b24f661d67cd4e98ac9b2ca9928c0f (patch)
treeb9c917fc783b6bdd15fa2781b607b34b3cf51606 /xmpp
parent462a537021f471579877eceb1dd6c47154d8052d (diff)
Multiple resources handling
Diffstat (limited to 'xmpp')
-rw-r--r--xmpp/component.go2
-rw-r--r--xmpp/handlers.go11
2 files changed, 7 insertions, 6 deletions
diff --git a/xmpp/component.go b/xmpp/component.go
index d1d0ddf..109d3d5 100644
--- a/xmpp/component.go
+++ b/xmpp/component.go
@@ -134,7 +134,7 @@ func Close(component *xmpp.Component) {
// close all sessions
for _, session := range sessions {
- session.Disconnect()
+ session.Disconnect("", true)
}
// save sessions
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 {