2013-01-18 16:53:38 -08:00
|
|
|
// Copyright 2013 Flo Lauber <dev@qatfy.at>. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// TODO(flo):
|
|
|
|
// - support password protected MUC rooms
|
|
|
|
// - cleanup signatures of join/leave functions
|
|
|
|
package xmpp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
nsMUC = "http://jabber.org/protocol/muc"
|
|
|
|
nsMUCUser = "http://jabber.org/protocol/muc#user"
|
|
|
|
)
|
|
|
|
|
|
|
|
// xep-0045 7.2
|
2014-11-26 04:34:13 -08:00
|
|
|
func (c *Client) JoinMUC(jid, nick string) {
|
|
|
|
if nick == "" {
|
|
|
|
nick = c.jid
|
|
|
|
}
|
|
|
|
fmt.Fprintf(c.conn, "<presence to='%s/%s'>\n"+
|
2013-01-18 16:53:38 -08:00
|
|
|
"<x xmlns='%s' />\n"+
|
|
|
|
"</presence>",
|
2014-11-26 04:34:13 -08:00
|
|
|
xmlEscape(jid), xmlEscape(nick), nsMUC)
|
2013-01-18 16:53:38 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// xep-0045 7.14
|
|
|
|
func (c *Client) LeaveMUC(jid string) {
|
2013-05-14 19:24:35 -07:00
|
|
|
fmt.Fprintf(c.conn, "<presence from='%s' to='%s' type='unavailable' />",
|
2013-01-18 16:53:38 -08:00
|
|
|
c.jid, xmlEscape(jid))
|
|
|
|
}
|