[JDEV] Adding own namespace
Constantin Nickonov
Nickonov at jabber.com
Fri Jun 13 14:35:06 CDT 2003
Try:
<iq type="get" id="1001">
<query xmlns="jabber:iq:private">
<score xmlns="lind:score"/>
</query>
</iq>
In some implementations, the name of the <score> element doesn't matter, but
you must have the namespace within.
> -----Original Message-----
> From: Bernino Lind [mailto:lind at hlgroup.dk]
> Sent: Friday, June 13, 2003 12:32 PM
> To: jdev at jabber.org
> Cc: faustoq at libero.it
> Subject: RE: [JDEV] Adding own namespace
>
>
> Ah J*...
>
> Like I said, I am lame.
>
> So the GET portion of this is not working.
>
> I have to go to a Champagne bar now, any takers to resolve my little
> error will be granted a toast.
>
> Its weekend.
>
> Best regards,
> Bernino
>
> -----Original Message-----
> From: jdev-admin at jabber.org [mailto:jdev-admin at jabber.org] On
> Behalf Of
> Bernino Lind
> Sent: Friday, June 13, 2003 8:15 PM
> To: jdev at jabber.org
> Cc: faustoq at libero.it
> Subject: RE: [JDEV] Adding own namespace
>
>
> Dear list, dear Fausto, Richard, Benoit and other relevant interested
> parties.
>
> Now it works.
>
> To all those lamers, slow-goers and other not so well equipped persons
> plus the ones whom are just too old to think fast like myself
> (but hey,
> Im better insured!) id like to give my knowledge away.
>
> What I did is, EXAMPLE (using postgres):
>
> 1. You want to create a game where you would like to store
> the score of
> the game in a relational database with SQL. 2. You would then like to
> use xdb_sql (see other docs to get it working) 3. You expand your DB
> model with what ever relevant tables, in this example I want
> to save the
> current date, the username, the gameid (I have multiple games) and the
> score:
>
> CREATE TABLE score (
> sid INTEGER PRIMARY KEY DEFAULT NEXTVAL('serial'),
> username VARCHAR(255) REFERENCES users(username) NOT NULL,
> gameid INTEGER NOT NULL,
> score INTEGER NOT NULL,
> date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
> );
>
> 4. Add in xdb_sql.xml (your SQL config) the relevant SQL bits, in this
> example:
>
> <!-- ****************** score ********************** -->
> <querydef name="score-set" dtd="2" type="set"
> namespace="lind:score">
> <text>INSERT INTO score (username,gameid,score) VALUES
> ('$$user$$', '$$gameid$$','$$score$$')</text>
> <user>$$user$$</user>
> <bindvar tag="gameid">$$gameid$$</bindvar>
> <bindvar tag="score">$$score$$</bindvar>
> </querydef>
>
> <querydef name="score-get" dtd="2" type="get"
> namespace="lind:score">
> <text>SELECT score, date FROM score WHERE username =
> '$$user$$'
> AND gameid='$$gameid$$'</text>
> <user>$$user$$</user>
> <bindvar tag="gameid">$$gameid$$</bindvar>
> <top-result><x xmlns='score:iq:get'/></top-result>
> <bindcol tag="domain" offset="0"/>
> <bindcol tag="file" offset="1"/>
> </querydef>
> </queries>
>
> 5. Add in you jabber.xml (your server configuration) a method for xdb:
>
> <xdb id="xdbscore">
> <host/>
> <ns>lind:score</ns>
> <load>
> <xdb_sql>/usr/local/lib/jabber/xdb_sql.so</xdb_sql>
> </load>
> <jabberd:include>/usr/local/etc/xdb_sql.xml</jabberd:include>
> </xdb>
>
> IMPORTANT NOTE: never use ns of jabber: - this is reserved for the
> jabber people...which is why my xmlns is called lind:score
>
> 6. Reload config
>
> 7. Check that it works and use this kind of method: lind at subsilo
> jabberd14/xdb_sql> telnet 192.168.0.166 5222 Trying 192.168.0.166...
> Connected to subsilo.subsilo.dk. Escape character is '^]'.
> <stream:stream
> to='192.168.0.166'
> xmlns='jabber:client'
> xmlns:stream='http://etherx.jabber.org/streams'>
> <?xml version='1.0'?><stream:stream
> xmlns:stream='http://etherx.jabber.org/streams' id='3EEA0D28'
> xmlns='jabber:client' from='192.168.0.166'>
>
>
>
> <iq id='auth2' type='set'>
> <query xmlns='jabber:iq:auth'>
> <username>jabberuser</username>
> <password>secret</password>
> <resource>telnet</resource>
> </query>
> </iq>
>
>
> <iq id='auth2' type='result'/>
>
>
> <presence/>
>
> <iq type="set" id="1001">
> <query xmlns="jabber:iq:private">
> <score xmlns="lind:score">
> <gameid>1</gameid>
> <score>12</score>
> </score>
> </query>
> </iq>
>
> <iq type='result' id='1001' from='jabberuser at 192.168.0.166/telnet'
> to='jabberuser at 192.168.0.166/telnet'/>
>
> The way to set your score is via the jabber:iq:private...
>
> 8. Doble checke that everything is in ordnung:
> jdb=# SELECT * from score ;
> sid | username | gameid | score | date
>
> -----+--------------------------+--------+-------+------------
> ----------
> ------
> 1 | jabberuser at 192.168.0.166 | 1 | 12 | 2003-06-13
> 20:11:40.774654
> 2 | jabberuser at 192.168.0.166 | 1 | 12 | 2003-06-13
> 20:11:54.546168
> (2 rows)
>
> jdb=#
>
> 9. Have an espresso and your favourite candy.
>
> Best regards,
> Bernino Lind
>
>
>
>
> -----Original Message-----
> From: jdev-admin at jabber.org [mailto:jdev-admin at jabber.org] On
> Behalf Of
> Bernino Lind
> Sent: Friday, June 13, 2003 6:49 PM
> To: jdev at jabber.org
> Subject: RE: [JDEV] Adding own namespace
>
>
> Dear Richard,
>
> Thats very fine with some rules...
>
> s/jabber/lind/g
>
> But I still need to have some knowledge on the actual implementation.
>
> It sounds as though you can help me Richard - howto implement the
> question in ask?
>
> best regards,
> Bernino Lind
>
> -----Original Message-----
> From: jdev-admin at jabber.org [mailto:jdev-admin at jabber.org] On
> Behalf Of
> Richard Dobson
> Sent: Friday, June 13, 2003 10:31 AM
> To: jdev at jabber.org
> Subject: Re: [JDEV] Adding own namespace
>
>
> If you are creating your own non standard namespaces you must not use
> the word jabber in it, you must use something different
> usually the name
> of your application or your surname e.g. lind:score.
>
> Richard
>
> ----- Original Message -----
> From: "Bernino Lind" <lind at hlgroup.dk>
> To: <jdev at jabber.org>
> Sent: Thursday, June 12, 2003 11:29 PM
> Subject: [JDEV] Adding own namespace
>
>
> > Dear list,
> >
> > I need to add a namespace for some development I am doing.
> >
> > Needed:
> > * store a game id with score and jid in database
> >
> > Aka:
> >
> > <iq type='set' to='score at my-host'>
> > <query xmlns='jabber:score'>
> > <gameid>1</gameid>
> > <score>123</score>
> > </query>
> > </iq>
> >
> > And ofcourse a "get" method to find the score of a particular user.
> >
> > I am very much in doubt of an implementation. I read about the
> > bloodbank example in some jep with jabber:x:data - but there is no
> > implementation guide so I dropped it.
> >
> > I also read the test:iq:url example - ditto problem.
> >
> > What I have done so far, by quessing, is:
> >
> > Add dtd=2 queries to the xdb_sql.xml configuration with a xmlns of
> > jabber:score. Add jabber:score to my jabber.xml configuration with
> > xdb_sql as storage method for all hosts for the xmlns jabber:score.
> >
> > I get 404 and 502: no go.
> >
> > Then I added service description and name. Still no go.
> >
> > In the browse section:
> > <service type="score" jid="score.192.168.0.166"
> name="score">
> > <ns>jabber:score</ns>
> > </service>
> >
> >
> > In the xdb section:
> > <xdb id="xdbscore">
> > <host/>
> > <ns>jabber:score</ns>
> > <load>
> > <xdb_sql>/usr/local/lib/jabber/xdb_sql.so</xdb_sql>
> > </load>
> > <jabberd:include>/usr/local/etc/xdb_sql.xml</jabberd:include>
> > </xdb>
> >
> >
> > Parallel to yahoo etc. gateway service sections:
> > <service id="score">
> > <host>score.192.168.0.166</host>
> > </service>
> >
> > In the xdb_sql:
> > <!-- ****************** score ********************** -->
> > <querydef name="score-set" dtd="2" type="set"
> > namespace="jabber:score">
> > <text>INSERT INTO score (username,gameid,score) VALUES
> > ('$$user$$', '$$gameid$$','$$score$$')</text>
> > <user>$$user$$</user>
> > <bindvar tag="gameid">$$gameid$$</bindvar>
> > <bindvar tag="score">$$score$$</bindvar>
> > </querydef>
> >
> > <querydef name="score-get" dtd="2" type="get"
> > namespace="jabber:score">
> > <text>SELECT score, date FROM score WHERE username =
> > '$$user$$' AND gameid='$$gameid$$'</text>
> > <user>$$user$$</user>
> > <bindvar tag="gameid">$$gameid$$</bindvar>
> > <top-result><x xmlns='score:iq:get'/></top-result>
> > <bindcol tag="domain" offset="0"/>
> > <bindcol tag="file" offset="1"/>
> > </querydef>
> > </queries>
> >
> > Can anyone send an example of how to configure the server to add a
> > namespace in this way?
> >
> > As you can see this is really the same question previously asked on
> > this
> > list: how to really use the dtd=2???
> >
> > best regards,
> > Bernino Lind
> >
> > _______________________________________________
> > 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
>
> _______________________________________________
> 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
>
> _______________________________________________
> jdev mailing list
> jdev at jabber.org
> http://mailman.jabber.org/listinfo/jdev
>
More information about the JDev
mailing list