Not logged in. · Lost password · Register
Forum: XMPP Protocol RSS
Avatar
cml #1
Member since Oct 2005 · 15 posts
Group memberships: Members
Show profile · Link to this post
Subject: Some problems about XMPP IM spec
hi~
1.I would like to know how to define a new message type.
ex.chat,error,groupchat,normal...etc.
 
2.What is the 'priority' mean? I couldn't understand the word 'resource' which in my cite below mean.
cite from http://www.ietf.org/rfc/rfc3921.txt
   The OPTIONAL <priority/> element contains non-human-readable XML
   character data that specifies the priority level of the resource....

3.<iq xmlns="jabber:client" id="agsXMPP_1" type="set" to="gmail.com"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>MiniClient</resource></bind></iq>
I want to know what does 'id' means.Why does it keep increase and send to server so many times?And if I feel like to know more about these messages where can I find the informations.

thanks a lot~ :D
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hi cml,

ID:
each packet in XMPP should have an ID.
I will explain it with an IQ. If you send an IQ to a user, for example to request his client version or time, you send the Iq Packet with a id. And the client or server that answers your request doesnt change the id when sending the response back to you. So you know by the ID that the result packet belongs to this request packet. This behaviour is used in the IqGrabber class and lots of other places in agsXMPP. The id could be anything. A string, a number, a guid. i just used a number and increase it all the time. And added agsXMPP before it, so you could see in the debug that the agsXMPP library is used in the product.

Resource an priority:
XMPP is different than other protocols like aim, msn, icq etc... You could have multiple logged in sessions at the same time. But each session needs another resource. username@server/resource is the full jabberid and must be unique. So you could log in once with your Desktop PC with the resource desktop and once with your smartphone and the resource smartphone.
Other users can send messages to your full Jid. So a message to your smartphone would look like this:
<message to='user@server/smartphone' type='chat'><body>Hi, how are you</body></message>
if you send the message without ressource like this:
<message to='user@server' type='chat'><body>Hi, how are you</body></message>
then we need the priority. When a message is sent to a bare Jid (Jid without resource) then the server must decide to whom he should route this message. And this is done with the priority. The resource with the highest priority gets the message. When there is a pat, then the resource which logged in later gets the message.
If you try to login twice with the same resource then the server kicks the connection that is already logged in.
If you are logged in at home with a client, go to office and log in there with another resource, then you have to take care about the priority. The priority from the office resource must be equal or higher than the home resource. Otherwise the messages will be delivered to the wrong client when other clients send them to a Bare jid.

message type:
error: is for error messages
chat: is for chat like messages: send this when you expect a fast reply
normal: is like email. Just a message but you dont expect a fast answer or no answer at all.
headline: The name sais everything. They are headlines
groupchat: is used for sending/receiving messages from/to a chatroom (IRC style chats)

Alex
Avatar
Alex #3
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
You will find teh XMPP specs also in nice HTML format here:
http://www.xmpp.org/specs/
Avatar
cml #4
Member since Oct 2005 · 15 posts
Group memberships: Members
Show profile · Link to this post
:oops:
Because of my poor english, one of my problems about message type seems misunderstanding you. I meant how can I define a new message type just belong to my own client and server, even they will be take as normal message in other server.

Thanks again~
Avatar
Alex #5
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
sorry, its not your english, its me not reading carefully enough ;-)
You should not define new message types. Existing clients will not understand it. The way to build custom messages and other packets is to extend the existing.

sample:
<message to='user@server' type=&quot;normal&quot;>
   <body>Test</body>
   <x xmlns='your_new_namespace>special stuff, can contain subnodes and attribs</x>
</message>
in the x-Tag with your namespace you can put your special stuff. Clients that dont know your extended protocols just display a normal message. So it breaks no other clients and extends your client. If you dont want other clients to display a message at all then remove the body tag.

Alex
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: