ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Net-XMPP2/samples/simple_example_1
Revision: 1.3
Committed: Sat Jul 7 12:39:45 2007 UTC (19 years, 3 months ago) by elmex
Branch: MAIN
Changes since 1.2: +13 -1 lines
Log Message:
fixed some bugs, redesigned disco mechanism, probably added some bugs,
added samples/disco_test example.

File Contents

# Content
1 #!/opt/perl/bin/perl
2 use strict;
3 use utf8;
4 use Event;
5 use AnyEvent;
6 use Net::XMPP2::Client;
7
8 my $j = AnyEvent->condvar;
9 my $cl = Net::XMPP2::Client->new;
10 $cl->add_account ('net_xmpp2@jabber.org', 'test');
11 $cl->reg_cb (
12 session_ready => sub {
13 my ($cl, $acc) = @_;
14 print "session ready\n";
15 $cl->send_message (
16 "Hi! I'm too stupid to adjust examples!" => 'elmex@jabber.org', undef, 'chat'
17 );
18 0
19 },
20 disconnect => sub {
21 my ($cl, $acc, $h, $p, $reas) = @_;
22 print "disconnect ($h:$p): $reas\n";
23 1
24 },
25 error => sub {
26 my ($cl, $acc, $err) = @_;
27 print "ERROR: " . $err->string . "\n";
28 1
29 },
30 message => sub {
31 my ($cl, $acc, $msg) = @_;
32 print "message from: " . $msg->from . ": " . $msg->any_body . "\n";
33 1
34 }
35 );
36
37 $cl->start;
38 $j->wait;
39