January 2002
Beginner
480 pages
13h 15m
English
Next in line to handle the incoming <iq/>
element is the iq_browse() function. Of course, if
we’ve already handled the element, iq_browse() won’t
even get a shot at responding. But if it did, it would proceed along
similar lines to the iq_version() function:
sub iq_browse {
my $node = shift;
debug("[iq_browse]");
return unless my $query = $node->getTag('', NS_BROWSE)
and $node->attr('type', IQ_GET);
debug("--> browse request");
$node = toFrom($node);
$node->attr('type', IQ_RESULT);
my $rss = $query->insertTag('service');
$rss->attr('type', 'rss');
$rss->attr('jid', $ID);
$rss->attr('name', $NAME);
$rss->insertTag('ns')->data(NS_REGISTER);
$c->send($node);
return r_HANDLED;
}
The only real difference is that we want this function to
handle IQ-gets in the jabber:iq:browse namespace
and return a browse result. Browsing will be discussed in greater detail in Section 10.3 in Chapter 10. For
now, though, let’s focus on returning a top-level browse result
that reflects what might be returned if a similar browse request were
made of the JSM, as described in Section 6.2.5 in Chapter 6.
Example 9-19 shows what iq_browse() will return.
RECV: <iq type="get" id="browser_JCOM_2" to="rss.qmacro.dyndns.org"> <query xmlns="jabber:iq:browse"/> </iq> SEND: <iq id='browser_JCOM_2' type='result' to='dj@qmacro.dyndns.org/winjab' from='rss.qmacro.dyndns.org'> <query xmlns='jabber:iq:browse'> ...
Read now
Unlock full access