AnyEvent-IRC
view release on metacpan or search on metacpan
lib/AnyEvent/IRC/Client.pm view on Meta::CPAN
package AnyEvent::IRC::Client;
use common::sense;
use Scalar::Util qw/weaken/;
use Encode;
use AnyEvent::Socket;
use AnyEvent::Handle;
use AnyEvent::IRC::Util
qw/prefix_nick decode_ctcp split_prefix
is_nick_prefix join_prefix encode_ctcp
split_unicode_string mk_msg/;
use base AnyEvent::IRC::Connection::;
lib/AnyEvent/IRC/Client.pm view on Meta::CPAN
sub dcc_initiate {
my ($self, $dest, $type, $timeout, $local_ip, $local_port) = @_;
$dest = $self->lower_case ($dest);
$type = lc $type;
my $id = ++$self->{dcc_id};
my $dcc = $self->{dcc}->{$id} = { id => $id, type => $type, dest => $dest };
weaken $dcc;
weaken $self;
$dcc->{timeout} = AnyEvent->timer (after => $timeout || 5 * 60, cb => sub {
$self->dcc_disconnect ($id, "TIMEOUT") if $self;
});
$dcc->{listener} = tcp_server undef, $local_port, sub {
my ($fh, $h, $p) = @_;
return unless $dcc && $self;
$dcc->{handle} = AnyEvent::Handle->new (
lib/AnyEvent/IRC/Client.pm view on Meta::CPAN
C<$timeout> is the connection try timeout in seconds. The default is 300 (5 minutes).
=cut
sub dcc_accept {
my ($self, $id, $timeout) = @_;
my $dcc = $self->{dcc}->{$id}
or return;
weaken $dcc;
weaken $self;
$dcc->{timeout} = AnyEvent->timer (after => $timeout || 5 * 60, cb => sub {
$self->dcc_disconnect ($id, "CONNECT TIMEOUT") if $self;
});
$dcc->{connect} = tcp_connect $dcc->{ip}, $dcc->{port}, sub {
my ($fh) = @_;
return unless $dcc && $self;
delete $dcc->{timeout};
lib/AnyEvent/IRC/Connection.pm view on Meta::CPAN
package AnyEvent::IRC::Connection;
use common::sense;
use AnyEvent;
use POSIX;
use AnyEvent::Socket;
use AnyEvent::Handle;
use AnyEvent::IRC::Util qw/mk_msg parse_irc_msg/;
use Object::Event;
use Scalar::Util qw/weaken/;
use base Object::Event::;
=head1 NAME
AnyEvent::IRC::Connection - An IRC connection abstraction
=head1 SYNOPSIS
use AnyEvent;
( run in 1.030 second using v1.01-cache-2.11-cpan-65fba6d93b7 )