JabChapter 9

From WikiContent

(Difference between revisions)
Jump to: navigation, search
(vandal rev.)
Line 1: Line 1:
[http://vivaphp.net/linzzi/wiki/images/5/6b/64.html female feet soles] [http://skfpt.com/css/styles/text926.htm pirates of the carribbean klaus badelt] [http://magneticarts.net/catalog/images/pixels/news-649.html tiger coloring pages] [http://www.1800high-speed.com/upload/media/article1784.html meridia diet pills] [http://lettershop-nyc.com/clientuploads/thumbs/topic2074.htm foster city real estate] [http://lettershop-nyc.com/clientuploads/thumbs/sitemap.html site] [http://amestudios.com/zen/zc1/images/thumbs/news-584-20090907.html software internet phone] [http://cyctecnologias.com/myadmin/backup/dump/topic-1281.htm processes solvox manufacturing company] [http://magneticarts.net/catalog/images/pixels/news-1129.html west indies cricket commentary] [http://attitude21n.com/claroline/images/news-1007-2009-08-30.html effects of viagra on females] [http://terrazadelpacifico.com/images/wpThumbnails/pics/new2070.htm us state counties] [http://terrazadelpacifico.com/images/wpThumbnails/pics/new656.htm lord of the mics videos] [http://turvisa.co.cr/chat/web/viajar/img/sitemap.html site] [http://itsmenotyou.com/wp-content/uploads/2006/article440.htm vdm sound 2.1.0] [http://nezda.com/michaeltchaney/tmp/files/index.htm links] [http://www.algenib.com/guestfriend/thumbs/comment-2382.html atenolol medication] [http://lanaplace.com/UserFiles/Video/movie/boqasc4tl.htm redline racing videos] [http://porodicni-forum.com/forum/store/files/sitemap.html http] [http://www.algenib.com/guestfriend/thumbs/comment-685.html glamourmodelsgonebad] [http://sipaa.org/wp-content/uploads/2008/12/article1526.html snow patrol wow tab] [http://porodicni-forum.com/forum/store/files/page1785.html audio 3g ringtones] [http://lettershop-nyc.com/clientuploads/thumbs/topic351.htm picture sneaky video] [http://fatbread.com/marybrann/images/article2559.html extended release morphine] [http://dsrblog.com/wp-content/uploads/2007/news-1674-2009-08-30.html office professional 2003 activation key] [http://attitude21n.com/claroline/images/news-881-2009-08-28.html nissan car drifting video] [http://nezda.com/michaeltchaney/tmp/files/index.htm sitemap] [http://nezda.com/michaeltchaney/tmp/files/text1562.htm singapore airline a380] [http://amestudios.com/zen/zc1/images/thumbs/news-1500-20090901.html latex galleries] [http://share-share.org/new/attachment/images/comment-1584.html agnitum firewall serial] [http://bistrobuzz.com/images/users/2/topic-387.htm liability insurance quotes] [http://turvisa.co.cr/chat/web/viajar/img/topic-1314.html leftover crack nazi white trash lyrics] [http://blogscr.com/wp-content/avatars/pics/index.html webmap] [http://cyctecnologias.com/myadmin/backup/dump/topic-713.htm mastering] [http://freepdmaterial.com/wpau-backup/dump/page-1422.html yellow pages canada] [http://freepdmaterial.com/wpau-backup/dump/page-477.html adobe audition 1.5 cracks] [http://amestudios.com/zen/zc1/images/thumbs/news-22-20090908.html order adderall online no prior prescription] [http://sociedadtolkiencr.com/images/descargas/pics/resource-650.html 2005 sales truck] [http://bistrobuzz.com/images/users/2/topic-2242.htm ativan book guest pregnancy ru site] [http://image-value.com/upload/docs/page1286.html uncle kracker follow me tab] [http://terrazadelpacifico.com/images/wpThumbnails/pics/new2678.htm sahara the movie official website] [http://blogscr.com/wp-content/avatars/pics/news-15-20090908.html erica campbell] [http://attitude21n.com/claroline/images/news-499-2009-08-29.html green guy linkorama] [http://blogscr.com/wp-content/avatars/pics/news-331-20090906.html amoxicillin clavulante] [http://vivaphp.net/linzzi/wiki/images/5/6b/1765.html applicaton of chemical oxygen demand for water treatment] [http://www.1800high-speed.com/upload/media/article465.html eminem myspace shake that video] [http://musaonce.com/wp-content/uploads/2008/page2358.html medieval womens dress] [http://www.catherders.com/bsblog/files/sitemap.htm page] [http://cyctecnologias.com/myadmin/backup/dump/topic-1137.htm icoo loader serial number] [http://vivaphp.net/linzzi/wiki/images/5/6b/964.html il2sturmovik.com] [http://studiopluscr.com/maps/clases/cls/text-2174.htm hugo montenegro]
[http://triexcellence.com/qapro/registration/files/article679.html 32 degrees icon e review] [http://alraauta.mukade.jp/678.html gay cumshots] [http://krifoundation.org/gallery/data/thumbnails/24/pics/topic-439.htm michelle branch goodbye to you] [http://even.com.au/archives/images/text1568.htm erotic free streaming video] [http://fur.bz/0left/zed02/dat/cgi/article-1797.htm eve 6 think twice] [http://fevcaraad.aikotoba.jp/r3i1frfxy.html how to make roman blinds] [http://northernlightsdaylilies.com/GardenDesigns/media/flash/page278.html gostosas] [http://audi-s.net/kprof/data/915/img/news-1994.html movie steele sydnee] [http://elficoc.0lx.net/6.html jeanna fine] [http://fevtroct.wakatono.jp/page882.html rifle stocks] [http://elficoc.0lx.net/index.html http] [http://fevtroct.wakatono.jp/page653.html el salvador] [http://krifoundation.org/gallery/data/thumbnails/24/pics/topic-1591.htm lesbian videos] [http://studenthelp.com/ehdek/files/text813.htm fair tax] [http://even.com.au/archives/images/sitemap.htm http] [http://qasnrmax.zouri.jp/article-91.html angela devi] [http://northerndaylily.com/wpThumbnails/pics/comment-1628.html movie porn sample teen] [http://zonvone.ojaru.jp/849.html cheap flights spain] [http://rsdmilitaria.com/images/icons/news-1091-2009-08-01.html jamcracker.com] [http://xacnrfum.michikusa.jp/article761.html child support] [http://freshwaterpearlspuppetry.com/holidayblog/media/2/topic-592.htm courtney wagner] [http://roowiraas.zouri.jp/417.html poems for mothers] [http://easfevwi.konjiki.jp/9kpe9ea1k.html julie robbins] [http://fur.bz/0left/zed02/dat/cgi/article-13.htm tira banks] [http://aleastr.amigasa.jp/page818.html teen chatrooms] [http://awreelwe.at-ninja.jp/488.html sunflowers wedding bouquets] [http://audi-s.net/kprof/data/915/img/news-538.html pensamientos] [http://bugboloh.0lx.net/index.html webmap] [http://janreel.namekuji.jp/3.html sun bbs] [http://peakdocs.com/ac/images/pics/article1132.html culture club] [http://faolosi.0lx.net/article-165.html hotaru akane] [http://exelib.com/webmasters/files/news-2378-20090811.html target printable coupon pharmacy] [http://freshwpearls.com/bubbleblog/media/2/1458.html pubis dysfunction] [http://lovartar.0lx.net/article55.html daniella rush] [http://fevcaraad.aikotoba.jp/vrdneun13.html cox cable] [http://awreelwe.at-ninja.jp/311.html notebook computer] [http://fur.bz/0left/zed02/dat/cgi/article-1549.htm data-base driven] [http://even.com.au/archives/images/text1794.htm lodging] [http://seancochran.com/images/thumbs/page1106.html tell it like it is] [http://triexcellence.com/qapro/registration/files/article1423.html ephedra hydroxycut original supplement] [http://fafafaric.biroudo.jp/page-985.html bianca beauchamp] [http://peakdocs.com/ac/images/pics/index.html url] [http://bugfvfa.himegimi.jp/article792.html cellular phones] [http://zezqeacke.xxxxxxxx.jp/96.html jesse jane] [http://triexcellence.com/qapro/registration/files/article2266.html belly tickle] [http://krifoundation.org/gallery/data/thumbnails/24/pics/topic-824.htm 516 971 contact] [http://northernlightsdaylilies.com/GardenDesigns/media/flash/page591.html ads frys mercury news] [http://ifanepal.org.np/images/icons/index.htm url] [http://rsdmilitaria.com/images/icons/news-1626-2009-08-02.html ethanol fuel] [http://roowiraas.zouri.jp/477.html hot cars]
=Groupchat, : Components, and Event Models=
=Groupchat, : Components, and Event Models=
<br>By now, you should have a
<br>By now, you should have a

Revision as of 14:21, 18 September 2009

Groupchat, : Components, and Event Models

By now, you should have a

good idea of how scripts interact with Jabber and how the core
elements such as <message/> and
<presence/> can be constructed and handled.

This chapter builds upon what we've already seen in Chapter 8 and introduces new concepts. We build a nosy assistant that joins a conference room and alerts us to words and phrases that we want it to listen for. There are two popular conference protocols, as mentioned in Section 6.2.6 the presence-based Groupchat protocol, and the jabber:iq:conference-based Conference protocol. The assistant recipe, a foray into the world of 'bots, takes a look at the original presence-based one.

As we've seen, programming within Jabber's event model is fairly straightforward. But what happens when you want to meld other components with event models of their own? We look at a couple of typical scenarios where this melding needs to happen. The first is a homage to the Trojan Room Coffee Machine (http://www.cl.cam.ac.uk/coffee/coffee.html), where we give life, or at least presence, to a coffeepot, using LEGO MINDSTORMS. The second is a Tk-based RSS headline viewer. Both the coffeepot and the Tk programming library have event loops of their own. With the coffeepot, we need to have a loop that polls the coffeepot's status, independently of the polling for incoming packets from the Jabber server. The Tk programming library's event model is similar to those of the Jabber programming libraries that are used in the recipes in this book, in that handlers are set up and a loop is started that listens for UI events. In both cases, we need to get these event loops to work in harmony with the Jabber libraries' event loops.

Building Jabber solutions without event loops is a Sisyphean task. The very nature of Jabber communication is event-based, and it's important to understand how to use the event features of the Jabber programming libraries and also how to be able to mesh those features with similar features in other libraries and systems.

We also look at extending messages and build a mechanism that delivers RSS headlines to clients who register with that mechanism. These headlines are carried using an extended message type. In fact, the RSS Delivery Mechanism is a component. The three recipes in Chapter 8, were Jabber clients, in that they connected to the Jabber network via the Jabber Session Manager (JSM) service. We look at the differences between programming a client and programming a component in this chapter and build a complete component that can be queried and interacted with using the third of Jabber's building blocks the <iq/> element.

Happy coding!

Keyword Assistant

Many of the Jabber core and peripheral developers hang out in a conference room called jdev hosted by the Conferencing component on the Jabber server running at jabber.org. While a lot of useful information is to be gleaned from listening to what goes on in jdev, it isn't possible to be there all the time. Conversations in jdev are logged to web pages, which can be used to visit after the fact to try to catch up with things; however, this can be a hopeless task. One solution is to build a 'bot that looks for specific keywords and Uniform Resource Locators (URLs) in the conversations in jdev and send those on as Jabber messages.

This script, keyassist, connects to a Jabber server, enters a conference room, and listens to the conversations, looking for certain words and phrases to be uttered. The keyassist script is given a bit of "intelligence" in that it can be interacted with and told, while running, to watch for (or stop watching for), certain words and phrases.

The keyassist script introduces us to programmatic interaction with the Conferencing component. Before looking at the script, however, let's have a brief overview of Conferencing in general.


The Conferencing component at jabber.org is conference.jabber.org. Details of the component instance configuration for such a Conferencing component can be found in Section 4.10, where we see that the component exists as a shared object library connected with the library load component connection method. This component provides general conferencing facilities, oriented around a conference room and conference user model.

A Jabber user can enter (or join) a conference room, thereby becoming a conference user identified by a nickname that is chosen upon entering that room. Nicknames are generally used in conference rooms to provide a modicum of privacy it is assumed that by default you don't want to let the other conference room members know your real JID.

The Conferencing component supports two protocols for user and room interaction: a simple one that provides basic features and a more complex one that provides the basic features plus facilities such as password-protected rooms and room descriptions Groupchat and Conference.

{{Note|There is a third protocol, called Experimentaliq:groupchat, which came between the Groupchat and Conference protocols. This reflected an experimental move to add features to the basic Groupchat protocol using IQ elements, the contents of which were qualified by a namespace jabber:iq:groupchat. This protocol has been dropped, and support for it exists only in certain versions of WinJab and JIM.


The Groupchat protocol is the simpler of the two and provides basic
functions for entering and exiting conference rooms and choosing
nicknames. : This Groupchat protocol is known as the presence-based
protocol, because the protocol is based upon
<presence/> elements used for room entry, exit, and
nickname determination. The Groupchat protocol has a nominal version
number of 1.0.
The Conference protocol offers more advanced features than the
Groupchat protocol and makes use of two IQ namespaces:
jabber:iq:conference and jabber:iq:browse. It has a
nominal protocol version number of 1.4, which reflects the version of
the Jabber server with which it is delivered. Sometimes this version
number is referred to as 0.4, such as in the downloadable tarball and
in the value returned in response to a "version query" on the
component itself, as shown in Example 9-1. : The version number isn't
that important. The main thing to keep in mind is that the component
that is called conference.so (see the reference to the
shared object library in Section 4.10.4) supports both the
Groupchat protocol and the Conference protocol. If you come across a
shared object library called groupchat.so, this is the
original Conferencing component that was made available with Jabber
server Version 1.0. This library supports only the Groupchat protocol.

Querying the Conferencing component's version

SEND: <iq type='get' to='conference.gnu.mine.nu'> <query xmlns='jabber:iq:version'/> </iq>

RECV: <iq to='dj@gnu.mine.nu/jarl' from='conference.gnu.mine.nu' type='result'> <query xmlns='jabber:iq:version'> <name>conference</name> <version>0.4</version> <os>Linux 2.4.2-2</os> </query> </iq> In this recipe we'll be using the simpler Groupchat protocol. It's widely used and easy to understand. Example 9-2 shows a typical element log from Groupchat-based activity. It shows a user, with the JID qmacro@jabber.com, entering a room called "cellar," hosted on the conference component at conf.merlix.dyndns.org, a room that currently has two other occupants who go by the nicknames flash and roscoe. The elements are from qmacro's perspective, and are all explained following the example.

The Groupchat protocol in action The user qmacro tries to enter the conference room with the nickname flash and fails:

SEND: <presence to='cellar@conf.merlix.dyndns.org/flash'/>

RECV: <presence to='qmacro@jabber.com/jarltk' from='cellar@conf.merlix.dyndns.org/flash' type='error'> <error code='409'>Conflict</error> </presence>

He tries again, this time with a different nickname, deejay, and is successful:

SEND: <presence to='cellar@conf.merlix.dyndns.org/deejay'/>

RECV: <presence to='qmacro@jabber.com/jarltk' from='cellar@conf.merlix.dyndns.org/flash'/>

RECV: <presence to='qmacro@jabber.com/jarltk' from='cellar@conf.merlix.dyndns.org/roscoe'/>

RECV: <presence to='qmacro@jabber.com/jarltk' from='cellar@conf.merlix.dyndns.org/deejay'/>

RECV: <message to='qmacro@jabber.com/jarltk' type='groupchat' from='cellar@conf.merlix.dyndns.org'> <body>deejay has become available</body> </message>

roscoe says hi, and qmacro waves back:

RECV: <message to='qmacro@jabber.com/jarltk' from='cellar@conf.merlix.dyndns.org/roscoe' type='groupchat' cnu=> <body>hi</body> </message>

SEND: <message to='cellar@conf.merlix.dyndns.org' type='groupchat'> <body>/me waves to everyone</body> </message>

flash sends a private message to qmacro:

RECV: <message to='qmacro@jabber.com/jarltk' from='cellar@conf.merlix.dyndns.org/flash' type='chat'> <body>Is that you, qmacro?</body> <thread>jarl1998911094</thread> </message>

Feeling left out of the conversation, roscoe leaves the room:

RECV: <presence to='qmacro@jabber.com/jarltk' type='unavailable' from='cellar@conf.merlix.dyndns.org/roscoe'/>

RECV: <message to='qmacro@jabber.com/jarltk' type='groupchat' from='cellar@conf.merlix.dyndns.org'> <body>roscoe has left</body> </message> Let's take the stages in Example 9-2 one by one.

Failed attempt to enter room
qmacro makes an attempt to enter the room using the Groupchat
protocol. This is done by sending a directed
<presence/> element to a particular JID that represents
the room and the chosen nickname. This JID is constructed as follows:

[room name]@[conference component]/[nickname]

In this example, the conferencing component is identified with the
hostname conf.merlix.dyndns.org. qmacro's choice of
nickname is flash:


Thus the following element is sent:

SEND: <presence to='cellar@conf.merlix.dyndns.org/flash'/>

The conference component determines that there is already someone
present in the room cellar@conf.merlix.dyndns.org with the
nickname flash, so qmacro is notified of this and
receives a directed presence with an <error/> tag:

RECV: <presence to='qmacro@jabber.com/jarltk' from='cellar@conf.merlix.dyndns.org/flash' type='error'> <error code='409'>Conflict</error> </presence>

Note that the <presence/> element has the type
error and comes from the artificial JID constructed in the
room entry attempt. The element is addressed to qmacro's real
JID, of courseqmacro@jabber.com/jarltk as otherwise it
wouldn't reach him. : The error code 409 and text "Conflict" tells
qmacro that the nickname conflicted with one already in the
room. This is a standard error code/text pair; Table 5-3 shows a
complete set of code/text pairs. : At this stage, qmacro is
not yet in the room.
Successful attempt to enter room
qmacro tries again, this time with a different nickname,

SEND: <presence to='cellar@conf.merlix.dyndns.org/deejay'/>

This time, there is no conflict
Personal tools