diff options
Diffstat (limited to 'xmpp')
-rw-r--r-- | xmpp/gateway/gateway.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/xmpp/gateway/gateway.go b/xmpp/gateway/gateway.go index dfe2ebf..981858d 100644 --- a/xmpp/gateway/gateway.go +++ b/xmpp/gateway/gateway.go @@ -3,6 +3,7 @@ package gateway import ( "encoding/xml" "github.com/pkg/errors" + "strconv" "strings" "sync" @@ -343,6 +344,20 @@ func SendPresence(component *xmpp.Component, to string, args ...args.V) error { return nil } +// SPAppendFrom appends numeric from and resource to varargs +func SPAppendFrom(oldArgs []args.V, id int64) []args.V { + newArgs := append(oldArgs, SPFrom(strconv.FormatInt(id, 10))) + newArgs = append(newArgs, SPResource(Jid.Resource)) + return newArgs +} + +// SimplePresence crafts simple presence varargs +func SimplePresence(from int64, typ string) []args.V { + args := []args.V{SPType(typ)} + args = SPAppendFrom(args, from) + return args +} + // ResumableSend tries to resume the connection once and sends the packet again func ResumableSend(component *xmpp.Component, packet stanza.Packet) error { err := component.Send(packet) |