Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
tjabber #1
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
Subject: Best way to extract muc errors?
I'm trying to setup a conference. In one case I get the error:

<iq xmlns="jabber:client" from="testroom2@XXXX" to="todd@XXXXX/test" type="error" id="agsXMPP_6"><query xmlns="http://jabber.org/protocol/muc#owner"><x xmlns="jabber:x:data" type="submit" /></query><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></iq>


I'm not exactly sure how best to extract this error out in a context that knows what the error is for. In other places I have code that looks like:
if (query.GetType() == typeof(agsXMPP.protocol.iq.privacy.Privacy))
{
  if (iq.Type == IqType.error)
  {
  }
}

I don't see this approach working for a URL based name space. Any thoughts on how to handle this?

thanks
Avatar
tjabber #2
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
Also, this failure was in response to an instant room creation request:

<iq xmlns="jabber:client" id="agsXMPP_6" type="set" to="testroom2@XXXXX"><query xmlns="http://jabber.org/protocol/muc#owner"><x xmlns="jabber:x:data" type="submit" /></query></iq>

The response was service not available so I guess that means I have to go through the longer chat room creation process?
Avatar
Alex #3
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hi tjabber,

it would be helpful when you post the complete xml log which includes the room creation packets.
When creating a chat room you normally have to configure it with a xdata form. But you can also create an instant room and accept the default configuration.

For IQs I suggest to send them always with the IqGrabber. The MucManager does this by default with all iqs.
The advantage of the IqGrabber is that you get the response in a defined callback. Routines like the following are not necessary because you know exactly in your callback which packet types you expect.
  1. if (query.GetType() == typeof(agsXMPP.protocol.iq.privacy.Privacy))
  2. {
  3.   ...
  4. }

SO you can check in your callback for errors with teh following code only:

  1. if (iq.Type == IqType.error)
  2. {
  3.  
  4. }
  5. else if(iq.Type == IqType.result)
  6. {
  7.  
  8. }

Alex
Avatar
tjabber #4
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
I figured out I needed to send presence to create a room so I just created the XML to do that. Apparently to make this work I also need to prepend "conference" to my server name. I noticed this by looking at the spark client XML when it created a conference.

Part of the problem I think is that data is spread everywhere in xmpp. So in response to my presence to create a room I get:
<presence xmlns="jabber:client" from="testroom2@conference.XXXX/first" to="todd@XXXX/test"><x xmlns="http://jabber.org/protocol/muc#user"><item role="moderator" affiliation="owner" jid="todd@XXXX/test" /><status code="201" /></x></presence>

How I am supposed to feed that into my state machine that's trying to handle conference setup? It doesn't tie back to my request at all.

Somehow I need to get to the status out of the packet. Information can be in presence, iq, or messages, and in no consistent place. Not your fault of course, but it's a little strange, especially when trying to deal with errors.
Avatar
Alex #5
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by tjabber:
I figured out I needed to send presence to create a room so I just created the XML to do that. Apparently to make this work I also need to prepend "conference" to my server name. I noticed this by looking at the spark client XML when it created a conference.

conferencing is a service of your server. In many cases its conference.youserverdomain.com. But this is not required and you can't make the assumption that its always conference and that all servers run a conferencing service. You have to discover the services using service discovery dynamically. The are examples for this in the MiniClient. The MiniClint does this also with the search services.

Quote by tjabber:
Part of the problem I think is that data is spread everywhere in xmpp. So in response to my presence to create a room I get:
<presence xmlns="jabber:client" from="testroom2@conference.XXXX/first" to="todd@XXXX/test"><x xmlns="http://jabber.org/protocol/muc#user"><item role="moderator" affiliation="owner" jid="todd@XXXX/test" /><status code="201" /></x></presence>

How I am supposed to feed that into my state machine that's trying to handle conference setup? It doesn't tie back to my request at all.

Somehow I need to get to the status out of the packet. Information can be in presence, iq, or messages, and in no consistent place. Not your fault of course, but it's a little strange, especially when trying to deal with errors.

The logic is not that hard. Groupchat messages have always the groupchat type. You can handle them easily with the MessageGrabber in your own callbacks.
Presences from groupchat participants are from the room jid where the resource is the nickname. So you need some logic which checks if this is a normal presence from a contact on your roster or a groupchat presence.

Did you look at the GroupChat code in the MiniClient? It does not support all the MUC features, but I think it gives you some ideas to get started.
And don't panic, I'm sure you will figure out all the information ;-). XMPP is very easy to get started with, but it also can get very complicated if you go deeper into the technology.

Alex
Avatar
tjabber #6
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
Good to know about the conference discovery process.

I was wondering if you had any thoughts on what would be the canonical way of extracting the status code from the presence packet? It seems necessary to do before sending out the presence reply, but I can't quite seem to connect the dots.

> So you need some logic which checks if this is a normal presence from a contact on your roster or a groupchat presence.

Ah, OK. Since each room will have a unique name that makes sense.

> And don't panic, I'm sure you will figure out all the information

I'm glad one of is :-)
Avatar
Alex #7
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by tjabber:
I was wondering if you had any thoughts on what would be the canonical way of extracting the status code from the presence packet? It seems necessary to do before sending out the presence reply, but I can't quite seem to connect the dots.

  1. <presence xmlns="jabber:client" from="testroom2@conference.XXXX/first" to="todd@XXXX/test"><x xmlns="http://jabber.org/protocol/muc#user"><item role="moderator" affiliation="owner" jid="todd@XXXX/test" /><status code="201" /></x></presence>

this is a normal presence packet which includes a agsXMPP.protocol.x.muc.User object. This object has a status property.
So just get this object with:

  1. agsXMPP.protocol.x.muc.User user = pres.SelectSingleElement(typeof(agsXMPP.protocol.x.muc.User)) as agsXMPP.protocol.x.muc.User;

you can also use the new generic SelectElement member which is in SVN.
I consider adding a new property to the presence object for MucUser. We don't want to add too much properties to Presence but  think Multi User Chat is a common use case and it would be good if its there.

Alex
Avatar
tjabber #8
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
Much cleaner than my approach. Thanks.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS