ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-XMPP2/samples/simple_example_1
Revision: 1.1
Committed: Thu Jul 5 20:26:27 2007 UTC (19 years, 2 months ago) by elmex
Branch: MAIN
Log Message:
added first real example

File Contents

# User Rev Content
1 elmex 1.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     connected => sub {
13     $cl->send_message (
14     "Hi! I'm too stupid to adjust examples!" => 'elmex@jabber.org'
15     );
16     0
17     },
18     message => sub {
19     my ($cl, $acc, $msg) = @_;
20     print "message from: " . $msg->from . ": " . $msg->any_body . "\n";
21     1
22     }
23     );
24    
25     $cl->start;
26     $j->wait;
27