view release on metacpan or search on metacpan
lib/AnyEvent/XMPP/SimpleConnection.pm view on Meta::CPAN
$self->disconnect ("EOF on connection to $self->{peer_host}:$self->{peer_port}: $!");
},
autocork => 1,
on_error => sub {
$self->disconnect ("Error on connection to $self->{peer_host}:$self->{peer_port}: $!");
},
on_read => sub {
my ($hdl) = @_;
my $data = $hdl->rbuf;
$hdl->rbuf = '';
$data = decode_utf8 $data;
$self->handle_data (\$data);
},
);
$self->connected
}, sub {
$timeout
};
lib/AnyEvent/XMPP/SimpleConnection.pm view on Meta::CPAN
}
sub end_sockets {
my ($self) = @_;
delete $self->{handle};
}
sub write_data {
my ($self, $data) = @_;
$self->{handle}->push_write (encode_utf8 ($data));
$self->debug_wrote_data (encode_utf8 ($data));
$self->{handle}->on_drain (sub {
$self->send_buffer_empty;
});
}
sub enable_ssl {
my ($self) = @_;
$self->{handle}->starttls ('connect');
$self->{ssl_enabled} = 1;
lib/AnyEvent/XMPP/Util.pm view on Meta::CPAN
=item B<resourceprep ($string)>
This function applies the stringprep profile for resources to C<$string>
and returns the result.
=cut
sub resourceprep {
my ($str) = @_;
decode_utf8 (idn_prep_resource (encode_utf8 ($str), 'UTF-8'))
}
=item B<nodeprep ($string)>
This function applies the stringprep profile for nodes to C<$string>
and returns the result.
=cut
sub nodeprep {
my ($str) = @_;
decode_utf8 (idn_prep_node (encode_utf8 ($str), 'UTF-8'))
}
=item B<prep_join_jid ($node, $domain, $resource)>
This function joins the parts C<$node>, C<$domain> and C<$resource>
to a full jid and applies stringprep profiles. If the profiles couldn't
be applied undef will be returned.
=cut
samples/conference_lister view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Ext::Disco;
use AnyEvent::XMPP::Ext::DataForm;
use Storable;
use XML::DOM::XPath;
our $J = AnyEvent->condvar;
our $datafile = "conferences.stor";
our $data = {};
samples/disco_info view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Ext::Disco;
use AnyEvent::XMPP::Ext::DataForm;
use AnyEvent::XMPP::Ext::Version;
use AnyEvent::XMPP::Namespaces qw/xmpp_ns/;
binmode STDOUT, ":utf8";
my ($jid, $pw, $discodest, $disconode) = @ARGV;
unless (@ARGV >= 3) {
warn "usage: disco_info <jid> <password> <disco-request-destination-jid> [<disco-node>]\n";
exit;
}
my $j = AnyEvent->condvar;
my $cl = AnyEvent::XMPP::Client->new (debug => 1);
samples/disco_version view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Ext::Version;
use POSIX qw/strftime/;
my ($jid,$pass) = qw/net_xmpp2@jabber.org test/;
($jid, $pass) = @ARGV if @ARGV;
sub timestamp {
strftime "%d%m%Y_%H%M", localtime (time);
samples/display_avatar view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use EV;
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Ext::VCard;
my $j = AnyEvent->condvar;
my $cl = AnyEvent::XMPP::Client->new (debug => 1);
$cl->add_account (@ARGV, undef, undef, {
initial_presence => -1, dont_retrieve_roster => 1
});
samples/find_servers view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Ext::Disco;
use AnyEvent::XMPP::Ext::DataForm;
use Storable;
use XML::DOM::XPath;
use IO::Handle;
use EVQ;
my @servers = map { s/^\s*(\S+)\s*$/\1/; $_ } <STDIN>;
samples/limit_searcher view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Util qw/simxml/;
use AnyEvent::XMPP::Ext::Disco;
my $j = AnyEvent->condvar;
my $cl = AnyEvent::XMPP::Client->new;
$cl->add_account ('net_xmpp2@jabber.org', 'test');
samples/retrieve_roster view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use AnyEvent;
use AnyEvent::XMPP::IM::Connection;
my $DEBUG = 0; # set to 1 if you want to see a protocol dump
my $TIMEOUT = 30; # timeout the whole program after $TIMEOUT seconds
binmode STDOUT, ":utf8";
my ($jid, $pass) = @ARGV;
my $j = AnyEvent->condvar;
my $con =
AnyEvent::XMPP::IM::Connection->new (
jid => $jid,
password => $pass,
initial_presence => -5,
);
samples/room_lister view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Ext::Disco;
use AnyEvent::XMPP::Ext::DataForm;
use Storable;
use XML::DOM::XPath;
use EVQ;
our $datafile = "room_data.stor";
our $data = {};
samples/sendmsg view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent;
use AnyEvent::XMPP::IM::Connection;
unless (@ARGV >= 3) { die "sendmsg <account jid> <password> <destination jid>\n" }
my $msg = do { local $/; <STDIN> };
my $dest = $ARGV[2];
my $j = AnyEvent->condvar;
samples/simple_component view on Meta::CPAN
#!/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',
samples/simple_example_1 view on Meta::CPAN
#!/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) = @_;
samples/simple_oob_retriever view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Ext::OOB;
use AnyEvent::XMPP::Ext::Disco;
my $j = AnyEvent->condvar;
my $cl = AnyEvent::XMPP::Client->new (debug => 1);
$cl->add_account ('net_xmpp2@jabber.org/oobtest', 'test');
samples/simple_register_example view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Ext::Registration;
use AnyEvent::XMPP::Util qw/split_jid/;
sub result {
my ($reg, $ok, $error, $form, $comment) = @_;
$comment ||= 'REGISTERED!';
if ($ok) {
print "$comment\n";
samples/store_avatar view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use EV;
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Ext::VCard;
my $j = AnyEvent->condvar;
my $cl = AnyEvent::XMPP::Client->new (debug => 1);
$cl->add_account ($ARGV[0], $ARGV[1], undef, undef, {
initial_presence => -1, dont_retrieve_roster => 1
});
samples/talkbot view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Ext::Disco;
use AnyEvent::XMPP::Ext::Version;
use AnyEvent::XMPP::Namespaces qw/xmpp_ns/;
my @msgs;
sub read_messages {
my ($msgs_file) = @_;
open my $f, $msgs_file
or die "Couldn't open messages file: '$msgs_file'\n";
(@msgs) = map { chomp; $_ } <$f>;
close $f;
}
binmode STDOUT, ":utf8";
my ($jid, $pw, $inputfile) = @ARGV;
unless (@ARGV >= 3) {
warn "usage: talkbot <jid> <password> <talkfile>\n";
exit;
}
read_messages ($inputfile);
samples/talkbot_channel view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent;
use AnyEvent::XMPP::Client;
use AnyEvent::XMPP::Ext::Disco;
use AnyEvent::XMPP::Ext::Version;
use AnyEvent::XMPP::Ext::MUC;
use AnyEvent::XMPP::Namespaces qw/xmpp_ns/;
use AnyEvent::XMPP::Util qw/node_jid res_jid/;
my @msgs;
samples/talkbot_channel view on Meta::CPAN
(@msgs) = map { chomp; $_ } <$f>;
close $f;
}
sub answer_to {
my ($msg) = @_;
my $talkmsg = $msgs[int (rand (@msgs))];
"You said '$msg' but... " . $talkmsg;
}
binmode STDOUT, ":utf8";
my ($jid, $pw, $inputfile, $room) = @ARGV;
unless (@ARGV >= 3) {
warn "usage: talkbot <jid> <password> <talkfile> [<conference room jid>]\n";
exit;
}
read_messages ($inputfile);
samples/test_client view on Meta::CPAN
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent;
use AnyEvent::XMPP qw/xep-86/;
use AnyEvent::XMPP::Client;
use Encode;
binmode STDOUT, ":utf8";
my $j = AnyEvent->condvar;
my $cl = AnyEvent::XMPP::Client->new (debug => 1);
$cl->set_presence ('away', 'I\'m a bot now.', 1);
$cl->add_account (@ARGV, undef, undef);
$cl->reg_cb (
connected => sub {
$cl->send_message ("Hello!" => 'elmex@jabber.org');
0
},