[EMAIL PROTECTED] schrieb:
you confused me even more...
I thought IM apps exchange xml messages (usually small),

let me explain XMPP with this small example of a session:

the client connects, open the socket and the XML Document
C->S: <?xml version="1.0"?>
C->S: <stream:stream xmlns:stream="http://etherx.jabber.org/streams"; xmlns="jabber:client" to="jabber.org" >

server accepts the socket and opens the XML document
S->C: <stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='jabber.org' id='596931'>

the client starts to authenticate
C->S: <iq type="get" to="jabber.org" id="auth_1" >
        <query xmlns="jabber:iq:auth">
                <username>alex</username>
        </query>
</iq>

S->C: <iq type="result" id="auth_1" >
        <query xmlns="jabber:iq:auth">
                <username>gnauck</username>
                <password/>
                <digest/>
                <resource/>
        </query>
      </iq>

C->S: <iq type="set" to="jabber.org" id="auth_2" >
        <query xmlns="jabber:iq:auth">
         <username>gnauck</username>
         <password>secret</password>
         <resource>Psi</resource>
        </query>
      </iq>


S->C: <iq type="result" id="auth_2" />

C->S: <message type="chat" to="[EMAIL PROTECTED]" >        
        <body>Test</body>
     </message>

Client closes the connection, which means it closes the XML Document
C->S: </stream:stream>

Server is closing the XML Doc too
S->C: </stream:stream>

you see we have 2 complete XML Documents. The client doc and the server doc. Our messages, also called stanzas are the 1st level child elements of the document. If you see the stanzas as a single xml doc and not in the context of the whole document you loose the namespace of the stanzas, and your software is not namespace correct. This is why parsing XMPP XML is a bit tricky and the most out of the box parsers don't work very well without modifying them. My exapmple shows the old jabber style authentication. It gets even more complicated when using SASL, START-TLS and other stuff which resets the stream and opens the document again.

> why do they exchange huge XML docs? It sounds not just bad, but
> unnecessary...

i don' think so. Because of this XMPP is a very clean and solid protocol. Clean, simple, powerful, extensible.....

Alex

Reply via email to