vitalyster/SharpXMPP

MUC Support

AtifShahzed opened this issue · 19 comments

I am using your library and pretty happy, I just looking for the MUC chat can you please guide me is this library supports MUC Conversation.

Thanks

XmppClient have BookmarkManager property and it has Join method, this will join MUC

I see,
I didn't find any snippet to join but there is method of join but it requires BookmarkedConference .
Can you please guide what room parameters do I need to add inside BookmarkedConference array object.
Following is my code.

BookmarkedConference bookmarkedConference = new BookmarkedConference();
bookmarkedConference.Add("room1@conference.blah.com");
this._xmppconnetction.BookmarkManager.Join
(bookmarkedConference);

Thanks

Set JID property of BookmarkedConference, like bookmarkedConference.JID = new JID("room1@conference.blah.com");

bookmarkedConference.JID Is Read-only.

Hi,

Ya it requires stanza what I am doing now on receive message I am parsing the message into BookmarkedConference but getting an error.

image

Here is the message which I am receiving as a join request.


Should I pass a new stanza with only JID on join.

Thanks

What is "join request"? Do you have it in XML form? Generally you can't parse message into conference, these are totally different XML elements.

Also you should not overwrite BookmarkManager property, it is created automatically and Rooms automatically populated with your bookmarked conferences.

Hi,

Here is the invitation request which is in XML.
<message to="321789@blah.com" from="room2@conference.blah.com" xmlns="jabber:client"> <x reason="Check this out!" password="1234" jid="room2@conference.blah.com" xmlns="jabber:x:conference" /> </message>

Hi,

I am trying to join using following code but still getting object reference error.

 BookmarkedConference room = new BookmarkedConference() { ID= "room1@conference.blah.com" };
    
        this._xmppconnetction.BookmarkManager = new  BookmarksManager(this._xmppconnetction);
        this._xmppconnetction.BookmarkManager.Join
  (room);

So,

  1. invitation request is a different XML element described in XEP-0249
  2. it is the child element of received message, so to extract room jid you need to find child element by name (x) and namespace (jabber:x:conference). You can use XElement methods on XMPPMessage (because XMPPMessage is System.Xml.Linq.XElement) to find that child element and get jid attribute from it. This should be easy if you familiar with LINQ to XML.
  3. You should not overwrite BookmarkManager again, it is already created.

Hi,

Thanks a lot yap I am able to extract the JID from the xml but when I try to write the join request as per your suggestion I am not able to set the JID because it is get only property as you can see on screenshot.

image

Hi,

Well i downloaded the source code and create new test app by adding the source project as a reference to debug the issue.
Finally I have identified the issue.

Here is the MUC room joining code.
this._xmppconnetction.BookmarkManager.Join(new BookmarkedConference()
{ JID = new JID("room2@conference.abc.com")});

When I debug it hits the Join method and grab the JID but NICK is null and that's why I was not able to join the room. Nick is also read only property.

Right now I am using the source code complied libraries but if you guide me is there any way to resolve this problem so I would happy to use the nugget package.

Thanks

Just checked out - public setter for JID was added recently and not yet released on NuGet.
Anyway, BookmarkedConference still XElement, JID and Nick are just shortcuts to XElement properties.
If you want to set nick, you need to add child element like:

var nick = new Element(XNamespace.Get(Namespaces.StorageBookmarks) + "nick");
nick.Value = "bla";
bookmarkedConference.Add(nick);

Hi,

That's great. Well I am able to JOIN the room and become the participant of the room.
Now I wanted to send the message to the room JID but the problem is message does not deliver to the room . My question is there any special settings are required to send the MUC room message.

Thanks

See XEP-0045: you should set type attribute to groupchat

Ok.

Yap there is a Send method but there is no parameter of type is available to set .
So is this functionality is available or I need to do it through Rest Api or is there any approach to set the custom elements of xml before sending the message.

Thanks

Set type on message with XElement methods (SetAttributeValue?) and then Send it

@vitalyster
Awsome !!!