[JDEV] Trouble in making my own JUD component in Jabber
Migs Paraz
map at internet.org.ph
Mon Nov 5 23:53:15 CST 2001
I resolved the previous problem - it was mismatched secrets - and I'm
getting the hang of using Jabber::Nodefactory. I wrote this little piece
of code to start off writing a JUD component/transport; I'm looking into
writing other sorts of transports later.
This one is supposed to give the list of search keys to a Jabber client.
I followed the jabber-programmers.pdf file.
But, when testing with Gabber, it just waits on the server. What is wrong?
Malformed output? Thanks.
#!/usr/bin/perl
# juday.pl, a JUD component
use Jabber::Connection;
use Jabber::NodeFactory;
use Jabber::NS qw(:all);
our $c = new Jabber::Connection(
ns => "jabber:component:accept",
server => 'localhost:1234',
localname => "jud.localhost",
log => 1,
);
$c->connect or die "oops: ".$c->lastError;
$c->register_handler('message', \&message);
$c->register_handler('iq', \&iq);
$c->auth("test");
# I wonder if this is needed for components.
$c->send('<presence/>');
$c->start();
$c->disconnect();
sub message {
my $node = shift;
print "Message --> ", $node->toStr, "\n";
}
sub iq {
my $node = shift;
print "IQ --> ", $node->toStr(), "\n";
# Different kinds of XML content
if (($node->attr("type") eq "get") &&
($node->getTag("query", "jabber:iq:search"))) {
my $id = $node->attr("id");
# Request for search parameters.
my $nf = new Jabber::NodeFactory;
my $tag = $nf->newNode("iq");
$tag->attr("type", "result");
$tag->attr("from", "jud.localhost");
$tag->attr("id", $id);
my $tag2 = $tag->insertTag("query", "jabber:iq:search");
$tag2->insertTag("first");
$tag2->insertTag("last");
$tag2->insertTag("nick");
$tag2->insertTag("email");
# I wonder if this key is needed.
$tag2->insertTag("key")->data("1");
$tag2->insertTag("instructions")->data("juday is here to help.");
# Send back to client
$c->send($tag);
}
}
More information about the JDev
mailing list