go-xmpp/cmd/fluuxmpp/xmppmuc.go
remicorniere 947fcf0432 PubSub protocol support (#142)
* PubSub protocol support
Added support for :
- XEP-0050   (Command))
- XEP-0060   (PubSub)
- XEP-0004   (Forms)

Fixed the NewClient function by adding parsing of the domain from the JID if no domain is provided in transport config.
Updated xmpp_jukebox example

* Delete useless pubsub errors

* README.md update
Fixed import in echo example

* Typo

* Fixed raw send on client example

* Fixed jukebox example and added a README.md
2020-01-09 15:33:11 +01:00

29 lines
668 B
Go

package main
import (
"github.com/bdlm/log"
"gosrc.io/xmpp"
"gosrc.io/xmpp/stanza"
)
func joinMUC(c xmpp.Sender, toJID *stanza.Jid) error {
return c.Send(stanza.Presence{Attrs: stanza.Attrs{To: toJID.Full()},
Extensions: []stanza.PresExtension{
stanza.MucPresence{
History: stanza.History{MaxStanzas: stanza.NewNullableInt(0)},
}},
})
}
func leaveMUCs(c xmpp.Sender, mucsToLeave []*stanza.Jid) {
for _, muc := range mucsToLeave {
if err := c.Send(stanza.Presence{Attrs: stanza.Attrs{
To: muc.Full(),
Type: stanza.PresenceTypeUnavailable,
}}); err != nil {
log.WithField("muc", muc).Errorf("error on leaving muc: %s", err)
}
}
}