ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-XMPP2/samples/simple_component
Revision: 1.1
Committed: Fri Jul 20 20:41:48 2007 UTC (19 years, 2 months ago) by elmex
Branch: MAIN
CVS Tags: HEAD
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

# Content
1 #!/opt/perl/bin/perl
2 use strict;
3 use utf8;
4 use Event;
5 use AnyEvent;
6 use Net::XMPP2::Component;
7 use Net::XMPP2::Util qw/install_default_debug_dump/;
8
9 my $j = AnyEvent->condvar;
10 my $c = Net::XMPP2::Component-> new (
11 domain => 'test.jabber.ta-sa.org',
12 server => 'sprawl',
13 port => 5347,
14 secret => 'lolfe',
15 );
16
17 install_default_debug_dump ($c);
18
19 if ($c->connect) {
20 $c->init;
21 $c->reg_cb (
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 '*dev@ve.symlynx.com', 'chat', undef,
39 body => "Hi!",
40 from => 'test@test.jabber.ta-sa.org'
41 );
42 }
43 );
44 } else {
45 print "connect error: $!\n";
46 $j->broadcast;
47 }
48
49 $j->wait;