[JDEV] How to create a new protocol?

Chris Chen ckchris at idream.net
Thu Jan 17 13:00:45 CST 2002


Yes, depending on your needs, you can either implement your "new protocol" 
by sending under a <iq> query message or through the <x> message.

If you're using <x> messages, then all you need to do is send a message 
that is similar to:

<message to="blah" type="normal" id="id_10001">
<x xmlns="my:own:namespace">
<test>data</test>
</x>
</message>


This should work out ok.. Then you just need to parse the x message out 
from the message and handle it accordingly.  Clients who do not support 
this X Message should ignore it by default (since client X Messages are 
mostly optional).  Thus, only your clients will know how to parse it and 
will respond to such requests.

WHat you can do is read up more on the other X Messages and you'll see how 
they are sent.

And remember not to use any namespace that starts out with "jabber" or 
"jabber:x" as those are reserved.

Thanks,
Chris

At 09:00 AM 1/16/2002, you wrote:
>so can something similar to this be done when sending messages.  for
>instance, can i somehow send data with each messages that only my client will
>understand?  seems like the "x" child element of the message element is what
>this is for?  can someone give a simple example of how i would do this?
>
>thanks, zak.
>
>On Tuesday 15 January 2002 09:54 am, you wrote:
> > You can create a new <iq> query type.. The problem you're having can be
> > solved by sending the message to a specific JID, not just the "standard
> > JID" of the client.  This means that you need to include the resource along
> > with it.  Otherwise, when you don't, the server intercepts it and actuallyg
> > vies you back what may be a public XML data.  THe request will not get
> > received by the client side.
> >
> > So try changing your:
> >
> > to="mycomponent.server"
> >
> > to:
> >
> > to="user at mycomponent.server/Server"
> >
> > or whatever your call your resource.
> >
> > Currently, your TO is actually a request to the server.  You need to add
> > the client's username to it and then the resource at the end.
> >
> > Thanks,
> > Chris
> >
> > At 03:03 AM 1/15/2002, you wrote:
> > >Hello!
> > >
> > >I want to create my own protocol, but there is no documentation on how to
> > >do this.
> > >
> > >Client sends:
> > ><iq type="get" from="client at server" to="mycomponent.server">
> > >  <query xmlns="jabber:mycomponent:party"/>
> > ></iq>
> > >
> > >Server returns:
> > ><iq type="result" from="mycomponent.server" to="client at server">
> > >  <query xmlns="jabber:mycomponents:party">
> > >   <party type="hacker party">
> > >    <participant>
> > >     <name>John Carmack</name>
> > >    </participant>
> > >    <participant>
> > >     <name>Alan Cox</name>
> > >    </participant>
> > >   </party>
> > >  </query>
> > ></iq>
> > >
> > >But no matter what data I send back to the client, Jabber strips any
> > >elements (subnodes to query) that are not included in an already existing
> > >XML name space.
> > >
> > >How do I define my own name space and tell Jabber what data is valid in
> > >that name space.
> > >
> > >When I test this Jabber returns my query with TWO instances of
> > >the attribute xmlns="jabber:mycomponents:party" in the query element and
> > >none of the subnodes in the query element.
> > >
> > >I can return vcards, time, last and other data in already defined name
> > >spaces, how do I create my own?
> > >
> > >/P
> > >
> > >
> > >_______________________________________________
> > >jdev mailing list
> > >jdev at jabber.org
> > >http://mailman.jabber.org/listinfo/jdev
> >
> > PGP at ldap://certserver.pgp.com/
> >
> > _______________________________________________
> > jdev mailing list
> > jdev at jabber.org
> > http://mailman.jabber.org/listinfo/jdev
>_______________________________________________
>jdev mailing list
>jdev at jabber.org
>http://mailman.jabber.org/listinfo/jdev

PGP at ldap://certserver.pgp.com/




More information about the JDev mailing list