File: simple_example_1

package info (click to toggle)
libanyevent-xmpp-perl 0.55-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 784 kB
  • ctags: 553
  • sloc: perl: 8,004; makefile: 13
file content (34 lines) | stat: -rw-r--r-- 857 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
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent::Impl::Tk;
use AnyEvent;
use AnyEvent::XMPP::Client;

my $j = AnyEvent->condvar;
my $cl = AnyEvent::XMPP::Client->new (debug => 1);
$cl->add_account ('net_xmpp2@jabber.org', 'test');
$cl->reg_cb (
   session_ready => sub {
      my ($cl, $acc) = @_;
      print "session ready\n";
      $cl->send_message (
         "Hi! I'm too lazy to adjust examples!" => 'elmex@jabber.org', undef, 'chat'
      );
   },
   disconnect => sub {
      my ($cl, $acc, $h, $p, $reas) = @_;
      print "disconnect ($h:$p): $reas\n";
      $j->broadcast;
   },
   error => sub {
      my ($cl, $acc, $err) = @_;
      print "ERROR: " . $err->string . "\n";
   },
   message => sub {
      my ($cl, $acc, $msg) = @_;
      print "message from: " . $msg->from . ": " . $msg->any_body . "\n";
   }
);
$cl->start;
$j->wait;