For the quickest reply, please use our new Customer Helpdesk and Feedback platform
 
   
 
Parsing the begining
Posted: 08 September 2009 01:54 PM   [ Ignore ]
Newbie
Rank
Total Posts:  5
Joined  2009-09-08

I have a small problem.
I would like to parse the

<stream:stream ...> 

from the begining of the XMPP conversation.

The closest thing to what I would like is

exmpp_xml:parse_document_fragment("String"). 

However, due to the fact that the XML element is not closed the only thing I get is a continue result.
I can understand why I get this result, but I would like to be able to process attributes in the <stream:stream ...>

To create I found

exmpp_stream:opening/
and
exmpp_stream:opening_reply 

,

To sum up, which is the best way to get a xmlel() of the form returned by exmpp_stream:opening from a Binary?

Many thanks,
Tiberiu

Profile
 
 
Posted: 08 September 2009 03:27 PM   [ Ignore ]   [ # 1 ]
Moderator
Rank
Total Posts:  28
Joined  2009-06-04

Hi,

what you need is the root_depth parameter,  you must specify it when creating the parser.  Using {root_depth, 1} exmpp won’t wait for elements above that level to be closed, and will deliver the start tag as you need.

You might find http://www.process-one.net/en/blogs/article/scalable_xmpp_bots_with_erlang_and_exmpp_part_i/  interesing;  this and other APIs trick are explained there.

Profile
 
 
Posted: 08 September 2009 11:33 PM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  5
Joined  2009-09-08

Super,
Thank you for the enlightening answer.

An other thing.
I have noticed that currently the receiving part of the server is scarcely implemented.
I have not found any correspondent to

exmpp_session 

on the server side.
For example there is a

exmpp_session:connect_TCP 

, but I have not found much on the server side.

One might argue that this leaves more freedom to the programmer, and I agree, but I am asking, maybe I missed something.

Regards
Tiberiu

Profile
 
 
Posted: 10 September 2009 08:51 PM   [ Ignore ]   [ # 3 ]
Newbie
Rank
Total Posts:  5
Joined  2009-09-08

An other question.
For SASL authentication there is no processing module on the server side?
I have found only the module that reads the XML tags, but nothing to process the base64 content (with the actual SASL data used in the authentication).

Are there any plans in this regard?
Or will you use the cyrsasl from ejabberd?

Profile
 
 
Posted: 11 September 2009 08:55 PM   [ Ignore ]   [ # 4 ]
Newbie
Rank
Total Posts:  5
Joined  2009-09-08

Small problem in the exmpp_iq processing part.

If one tries to process <iq> elements like the ones involved in XEP-0078:

<iq type='get' to='shakespeare.lit' id='auth1'>
  <
query x mlns 'jabber:iq:auth' />
</
iq

exmpp_iq:xmlel_to_iq/1 cannot process it, because it does not have a namespace.

exmpp_xml:parse_document() 
#xmlel{ns = undefined,declared_ns = [],name = iq,
        
attrs [#xmlattr{ns = undefined,name = type,
                          
value = <<"get">>},
                 
#xmlattr{ns = undefined,name = to,
                          
value = <<"shakespeare.lit">>},
                 
#xmlattr{ns = undefined,name = id,value = <<"auth1">>}],
        
children [#xmlcdata{cdata = <<"\n">>},
                    #xmlcdata{cdata = <<"  ">>},
                    #xmlel{ns = 'jabber:iq:auth',
                           
declared_ns [{'jabber:iq:auth',none}],
                           
name 'query',attrs [],children []},
                    
#xmlcdata{cdata = <<"\n">>}]} 

exmpp_xml:xmlel_to_iq(Alfa) yields

** exception errorno function clause matching exmpp_iq:xmlel_to_iq 
Profile
 
 
Posted: 14 September 2009 06:54 PM   [ Ignore ]   [ # 5 ]
Moderator
Rank
Total Posts:  28
Joined  2009-06-04

Hi,

that element is coming from a c2s stream, the iq WILL be in the jabber:client namespace. as defined in the stream start.
If you are parsing it directly as a standalone document,  you are missing the default namespace for it.

For testing, you can explicitly define the stanza namespace, like

exmpp_xml:parse_document(”<iq > ...</iq> “)

Profile
 
 
Posted: 22 September 2009 03:52 PM   [ Ignore ]   [ # 6 ]
Newbie
Rank
Total Posts:  5
Joined  2009-09-08

Where can I submit a patch/updated version of the exmpp_nss.hrl?
The one in the svn has some namespaces (e.g. jingle) outdated.
I manually updated them and now have a custom exmpp_nss.hrl

Profile
 
 
Posted: 22 September 2009 05:45 PM   [ Ignore ]   [ # 7 ]
Moderator
Rank
Total Posts:  28
Joined  2009-06-04

Hi, you can create a ticket here https://support.process-one.net/browse/EXMPP

Note that the set of known namespaces, attributes and elements is generated automatically from the spec lists (these files are on include/internal/exmpp_known_*.hrl).
Did you try to regenerate it instead of modify it by hand?  (look at the make-spec-list and extract-known-from-spec scripts)

The XEP are allways evolving, so you are right,  exmpp probably is outdated on many of them, but should be possible to completely re-generate them if you ask for.

Profile