ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Net-XMPP2/samples/test_client
Revision: 1.2
Committed: Sat Apr 21 13:51:39 2007 UTC (19 years, 5 months ago) by elmex
Branch: MAIN
Changes since 1.1: +5 -1 lines
Log Message:
implemented the (hopefully) last bits of important error reporting.
Net::XMPP was released at the beginngin of this month - damn, i was
too slow. But i've taken a look at their code. 17000 lines of code
vs. my ~4500 LoC.
Also their Java-API is really a mess...

File Contents

# Content
1 #!/opt/perl/bin/perl
2 use strict;
3 use utf8;
4 use Event;
5 use AnyEvent;
6 use XML::Twig;
7 use Net::XMPP2 qw/xep-86/;
8 use Net::XMPP2::Client;
9 use Encode;
10
11 sub dumpxml {
12 my $data = shift;
13 my $t = XML::Twig->new;
14 if ($t->safe_parse ("<deb>$data</deb>")) {
15 $t->set_pretty_print ('indented');
16 $t->print;
17 print "\n";
18 } else {
19 print "[$data]\n";
20 }
21 }
22
23 binmode STDOUT, ":utf8";
24
25 my $j = AnyEvent->condvar;
26
27 my $cl = Net::XMPP2::Client->new;
28 $cl->add_account ('elmex@jabber.org/Net::XどなPP2', 'xxxxxxxx');
29 $cl->reg_cb (
30 connected => sub {
31 $cl->send_message ("Hello!" => 'elmex@jabber.org');
32 0
33 },
34 sasl_error => sub {
35 my ($cl, $acc, $error) = @_;
36 print "SASL ERROR".$error->string."\n";
37 }
38 );
39
40 $cl->start;
41
42 $j->wait;