Debian Codegraph @

samples/simple_component

raw
1 #!/opt/perl/bin/perl
2 use strict;
3 use utf8;
4 use AnyEvent;
5 use AnyEvent::XMPP::Component;
6 use AnyEvent::XMPP::Util qw/install_default_debug_dump/;
7
8 my $j = AnyEvent->condvar;
9 my $c = AnyEvent::XMPP::Component-> new (
10 domain => 'test.jabber.ta-sa.org',
11 server => 'localhost',
12 port => 5347,
13 secret => 'lolfe',
14 );
15
16 install_default_debug_dump ($c);
17
18 $c->reg_cb (
19 connect => sub {
20 warn "connected...\n";
21 },
22 error => sub {
23 my ($c, $e) = @_;
24 warn "ERROR: " . $e->string . "\n";
25 1
26 },
27 disconnect => sub {
28 my ($c, $h, $p, $r) = @_;
29 warn "DISCON @_\n";
30 1
31 },
32 session_ready => sub {
33 my ($c) = @_;
34
35 print "component ready!\n";
36
37 $c->send_message (
38 '*[email protected]', 'chat', undef,
39 body => "Hi!",
40 from => '[email protected]'
41 );
42 }
43 );
44 $c->connect;
45
46 $j->wait;