ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-XMPP2/samples/simple_example_1
Revision: 1.5
Committed: Fri Jul 20 20:41:48 2007 UTC (19 years, 2 months ago) by elmex
Branch: MAIN
Changes since 1.4: +7 -2 lines
Log Message:
lots of changes. added as_string to Net::XMPP2::Node to restore
the original xml document part of a stanza or subtree.
also implemented the jabber component protocol.

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 elmex 1.5 my $cl = Net::XMPP2::Client->new (debug => 1);
10     $cl->add_account ('net_xmpp2@jabber.org/ねどだ', 'test');
11 elmex 1.1 $cl->reg_cb (
12 elmex 1.2 session_ready => sub {
13 elmex 1.3 my ($cl, $acc) = @_;
14     print "session ready\n";
15 elmex 1.1 $cl->send_message (
16 elmex 1.3 "Hi! I'm too stupid to adjust examples!" => 'elmex@jabber.org', undef, 'chat'
17 elmex 1.1 );
18     0
19     },
20 elmex 1.5 recv_stanza_xml => sub {
21     my ($cl, $acc, $node) = @_;
22     print 'STANZA:' . $node->as_string . "\n";
23     1
24     },
25 elmex 1.3 disconnect => sub {
26     my ($cl, $acc, $h, $p, $reas) = @_;
27     print "disconnect ($h:$p): $reas\n";
28     1
29     },
30     error => sub {
31     my ($cl, $acc, $err) = @_;
32     print "ERROR: " . $err->string . "\n";
33     1
34     },
35 elmex 1.1 message => sub {
36     my ($cl, $acc, $msg) = @_;
37     print "message from: " . $msg->from . ": " . $msg->any_body . "\n";
38     1
39     }
40     );
41     $cl->start;
42     $j->wait;