[jdev] Question about Jabber principles

Andrew Plotkin erkyrath at eblong.com
Mon Mar 20 11:28:05 CST 2006


I am working on a small piece of our Volity project, and I see several 
ways to do it. They'll all work, but I'm not sure which is most in tune 
with the zen of Jabber.

What I want to do is send a game invitation as part of a <message>. (Could 
be either IM or group-chat.) This is a set of fields; if one of our Volity 
clients receives it, the invitation will be displayed with appropriate UI 
("Do you want to join this game? [] yes [] no" and so on.) If a generic 
client receives the message, it should ignore the invitation part and 
display it as a standard message.

So option 1 would be to define some new protocol, maybe with a JEP (if any 
other clients want to handle the invitation info), and stick the fields 
directly into a custom element:

<message to="..." from="..." type="normal">
   <body>Play a game!</body>
   <invitation xmlns="http://volity.org/protocol/invite">
     <table>...</table>
     <referee>...</referee>
   </invitation>
</message>

(There are more fields than that; I'm simplifying here.)

This is fine, except that we may add or redefine fields as we expand our 
goals. And I don't want to change the XML schema every time that happens. 
Okay, Jabber has a way to handle that, which is data forms. So, option 2:

<message to="..." from="..." type="normal">
   <body>Play a game!</body>
   <invitation xmlns="http://volity.org/protocol/invite">
     <x xmlns="jabber:x:data" type="result">
       <field var="table"><value>...</value></field>
       <field var="referee"><value>...</value></field>
     </x>
   </invitation>
</message>

But then I notice JEP-0068, and I think maybe I can do this without any 
custom protocol at all. Option 3:

<message to="..." from="..." type="normal">
   <body>Play a game!</body>
   <x xmlns="jabber:x:data" type="result">
     <field var="FORM_TYPE" type="hidden">
       <value>http://volity.org/protocol/form/invite</value>
     </field>
     <field var="table"><value>...</value></field>
     <field var="referee"><value>...</value></field>
   </x>
</message>

So our client watches for a result form of the appropriate FORM_TYPE, and 
other clients ignore the extraneous (to them) form.

Which of these is most friendly to the Jabber system? We've gotten this 
far by using existing JEPs, so I have a slight preference to *not* 
introduce new Jabber protocol. But I'm more interested in figuring out 
what will work right with existing and future Jabber software.

--Z

-- 
"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
*
Making a saint out of Reagan is sad. Making an idol out of Nixon ("If the
President does it then it's legal") is contemptible.



More information about the JDev mailing list