Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MUC Implementation #101

Open
kylegibbons opened this issue Aug 13, 2019 · 1 comment
Open

MUC Implementation #101

kylegibbons opened this issue Aug 13, 2019 · 1 comment

Comments

@kylegibbons
Copy link

Is joining a MUC implemented in this library?

I looked around and found a few issues mentioning MUC that seem to indicate it is implemented, but I can't find any documentation on how to actually use it.

Could you point me in the right direction? Thanks!

@Kroev
Copy link

Kroev commented Aug 26, 2019

Yeah i had to fiddle a bit too but joining a MUC is simple, once you got the hang of it. Looking into XMPP documentation also helps, see XEP0045.

I did it in the postconnect handler of the streammanger here but you should be able to do it whenever you want, as long as the client is connected

func postConnect(s xmpp.Sender) {
	client, ok := s.(*xmpp.Client)
	if !ok {
		fmt.Println("post connect sender not a client, cannot proceed")
		//error handling 
	}
       
        //I used uuids to make sure the id is unique
	uuid, _ := uuid.NewV4()
	id := uuid.String()

	//prepare presence for joining the MUC
	presence := stanza.NewPresence(stanza.Attrs{
		To:   "<mucroom>@<xmppdomain_supporting_muc>/<muc_nickname>",//fill the fields accordingly
		From: client.Session.BindJid,
		Id:   id,
	})
        
        //as stated in the XEP0045 documentation, you have to tell that you are able to speak muc
	presence.Extensions = append(presence.Extensions, stanza.MucPresence{})

        //send the stuff and actually join the MUC
	err := client.Send(presence)
	if err != nil {
		//err handling
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants