File: simple_component

package info (click to toggle)
libanyevent-xmpp-perl 0.52-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 896 kB
  • sloc: perl: 7,937; makefile: 12
file content (46 lines) | stat: -rw-r--r-- 924 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent;
use AnyEvent::XMPP::Component;
use AnyEvent::XMPP::Util qw/install_default_debug_dump/;

my $j = AnyEvent->condvar;
my $c = AnyEvent::XMPP::Component-> new (
           domain => 'test.jabber.ta-sa.org',
           server => 'localhost',
           port   => 5347,
           secret => 'lolfe',
        );

install_default_debug_dump ($c);

$c->reg_cb (
   connect => sub {
      warn "connected...\n";
   },
   error => sub {
      my ($c, $e) = @_;
      warn "ERROR: " . $e->string . "\n";
      1
   },
   disconnect => sub {
      my ($c, $h, $p, $r) = @_;
      warn "DISCON @_\n";
      1
   },
   session_ready => sub {
      my ($c) = @_;

      print "component ready!\n";

      $c->send_message (
         '*dev@ve.symlynx.com', 'chat', undef,
         body => "Hi!",
         from => 'test@test.jabber.ta-sa.org'
      );
   }
);
$c->connect;

$j->wait;