r45356 - in /trunk/libanyevent-irc-perl: Changes META.yml Makefile.PL README debian/changelog lib/AnyEvent/IRC.pm lib/AnyEvent/IRC/Client.pm lib/AnyEvent/IRC/Connection.pm
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Sun Oct 4 16:24:20 UTC 2009
Author: jawnsy-guest
Date: Sun Oct 4 16:24:15 2009
New Revision: 45356
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=45356
Log:
New upstream release
Modified:
trunk/libanyevent-irc-perl/Changes
trunk/libanyevent-irc-perl/META.yml
trunk/libanyevent-irc-perl/Makefile.PL
trunk/libanyevent-irc-perl/README
trunk/libanyevent-irc-perl/debian/changelog
trunk/libanyevent-irc-perl/lib/AnyEvent/IRC.pm
trunk/libanyevent-irc-perl/lib/AnyEvent/IRC/Client.pm
trunk/libanyevent-irc-perl/lib/AnyEvent/IRC/Connection.pm
Modified: trunk/libanyevent-irc-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-irc-perl/Changes?rev=45356&op=diff
==============================================================================
--- trunk/libanyevent-irc-perl/Changes (original)
+++ trunk/libanyevent-irc-perl/Changes Sun Oct 4 16:24:15 2009
@@ -1,4 +1,9 @@
Revision history for AnyEvent::IRC
+
+0.9 Mon Sep 28 14:51:29 CEST 2009
+ - made AnyEvent::IRC::Client connection object reusable.
+ - documented that the 'heap' member of the AE::IRC::* objects
+ can be used to store any data.
0.81 Mon Aug 10 09:43:29 CEST 2009
- fixed some sample scripts.
Modified: trunk/libanyevent-irc-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-irc-perl/META.yml?rev=45356&op=diff
==============================================================================
--- trunk/libanyevent-irc-perl/META.yml (original)
+++ trunk/libanyevent-irc-perl/META.yml Sun Oct 4 16:24:15 2009
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: AnyEvent-IRC
-version: 0.81
+version: 0.9
abstract: An event system independend IRC protocol module
author:
- Robin Redeker <elmex at ta-sa.org>
@@ -8,16 +8,19 @@
distribution_type: module
configure_requires:
ExtUtils::MakeMaker: 0
+build_requires:
+ ExtUtils::MakeMaker: 0
requires:
- AnyEvent: 0
+ AnyEvent: 5.111
common::sense: 0
Object::Event: 0.6
+ Scalar::Util: 0
Test::More: 0
no_index:
directory:
- t
- inc
-generated_by: ExtUtils::MakeMaker version 6.46
+generated_by: ExtUtils::MakeMaker version 6.55_02
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
Modified: trunk/libanyevent-irc-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-irc-perl/Makefile.PL?rev=45356&op=diff
==============================================================================
--- trunk/libanyevent-irc-perl/Makefile.PL (original)
+++ trunk/libanyevent-irc-perl/Makefile.PL Sun Oct 4 16:24:15 2009
@@ -11,9 +11,10 @@
PL_FILES => {},
PREREQ_PM => {
'Test::More' => 0,
- 'AnyEvent' => 0,
+ 'AnyEvent' => '5.111',
'Object::Event' => '0.6',
'common::sense' => 0,
+ 'Scalar::Util' => 0,
},
dist => {
COMPRESS => 'gzip -9f',
Modified: trunk/libanyevent-irc-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-irc-perl/README?rev=45356&op=diff
==============================================================================
--- trunk/libanyevent-irc-perl/README (original)
+++ trunk/libanyevent-irc-perl/README Sun Oct 4 16:24:15 2009
@@ -2,7 +2,7 @@
AnyEvent::IRC - An event system independend IRC protocol module
VERSION
- Version 0.81
+ Version 0.9
SYNOPSIS
Using the simplistic AnyEvent::IRC::Connection:
@@ -148,8 +148,8 @@
And these people have helped to work on AnyEvent::IRC:
- * Maximilian Gaß - Added support for ISUPPORT and CASEMAPPING.
- * Zaba - Thanks for the useful input about IRC.
+ * Maximilian Gass - Added support for ISUPPORT and CASEMAPPING.
+ * Zaba - Thanks for the useful input about IRC.
COPYRIGHT & LICENSE
Copyright 2006-2009 Robin Redeker, all rights reserved.
Modified: trunk/libanyevent-irc-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-irc-perl/debian/changelog?rev=45356&op=diff
==============================================================================
--- trunk/libanyevent-irc-perl/debian/changelog (original)
+++ trunk/libanyevent-irc-perl/debian/changelog Sun Oct 4 16:24:15 2009
@@ -1,8 +1,12 @@
-libanyevent-irc-perl (0.81-2) UNRELEASED; urgency=low
+libanyevent-irc-perl (0.90-1) UNRELEASED; urgency=low
+ [ Jonathan Yu ]
+ * New upstream release
+
+ [ Ryan Niebur ]
* Update jawnsy's email address
- -- Ryan Niebur <ryanryan52 at gmail.com> Tue, 01 Sep 2009 21:17:59 -0700
+ -- Jonathan Yu <jawnsy at cpan.org> Sun, 04 Oct 2009 08:21:06 -0400
libanyevent-irc-perl (0.81-1) unstable; urgency=low
Modified: trunk/libanyevent-irc-perl/lib/AnyEvent/IRC.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-irc-perl/lib/AnyEvent/IRC.pm?rev=45356&op=diff
==============================================================================
--- trunk/libanyevent-irc-perl/lib/AnyEvent/IRC.pm (original)
+++ trunk/libanyevent-irc-perl/lib/AnyEvent/IRC.pm Sun Oct 4 16:24:15 2009
@@ -8,11 +8,11 @@
=head1 VERSION
-Version 0.81
+Version 0.9
=cut
-our $VERSION = '0.81';
+our $VERSION = '0.9';
=head1 SYNOPSIS
@@ -169,8 +169,8 @@
And these people have helped to work on L<AnyEvent::IRC>:
- * Maximilian Gaß - Added support for ISUPPORT and CASEMAPPING.
- * Zaba - Thanks for the useful input about IRC.
+ * Maximilian Gass - Added support for ISUPPORT and CASEMAPPING.
+ * Zaba - Thanks for the useful input about IRC.
=head1 COPYRIGHT & LICENSE
Modified: trunk/libanyevent-irc-perl/lib/AnyEvent/IRC/Client.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-irc-perl/lib/AnyEvent/IRC/Client.pm?rev=45356&op=diff
==============================================================================
--- trunk/libanyevent-irc-perl/lib/AnyEvent/IRC/Client.pm (original)
+++ trunk/libanyevent-irc-perl/lib/AnyEvent/IRC/Client.pm Sun Oct 4 16:24:15 2009
@@ -1,5 +1,7 @@
package AnyEvent::IRC::Client;
use common::sense;
+
+use Scalar::Util qw/weaken/;
use AnyEvent::Socket;
use AnyEvent::Handle;
@@ -293,6 +295,9 @@
=item $cl = AnyEvent::IRC::Client->new ()
This constructor takes no arguments.
+
+B<NOTE:> You are free to use the hash member C<heap> to store any associated
+data with this object. For example retry timers or anything else.
=cut
@@ -332,15 +337,28 @@
$self->reg_cb (disconnect => \&disconnect_cb);
- $self->reg_cb (irc_437 => \&change_nick_login_cb);
- $self->reg_cb (irc_433 => \&change_nick_login_cb);
-
$self->reg_cb (irc_332 => \&rpl_topic_cb);
$self->reg_cb (irc_topic => \&topic_change_cb);
$self->reg_cb (ctcp => \&ctcp_auto_reply_cb);
$self->reg_cb (registered => \®istered_cb);
+
+ $self->{def_nick_change} = $self->{nick_change} =
+ sub {
+ my ($old_nick) = @_;
+ "${old_nick}_"
+ };
+
+ $self->_setup_internal_dcc_handlers;
+
+ $self->cleanup;
+
+ return $self;
+}
+
+sub cleanup {
+ my ($self) = @_;
$self->{channel_list} = { };
$self->{isupport} = { };
@@ -348,15 +366,28 @@
$self->{prefix_chars} = '@+';
$self->{prefix2mode} = { '@' => 'o', '+' => 'v' };
$self->{channel_chars} = '#&';
- $self->{def_nick_change} = $self->{nick_change} =
- sub {
- my ($old_nick) = @_;
- "${old_nick}_"
- };
-
- $self->_setup_internal_dcc_handlers;
-
- return $self;
+
+ $self->{change_nick_cb_guard} =
+ $self->reg_cb (
+ irc_437 => \&change_nick_login_cb,
+ irc_433 => \&change_nick_login_cb,
+ );
+
+ delete $self->{dcc};
+ delete $self->{dcc_id};
+ delete $self->{_tmp_namereply};
+ delete $self->{last_pong_recv};
+ delete $self->{last_ping_sent};
+ delete $self->{_ping_timer};
+ delete $self->{con_queue};
+ delete $self->{chan_queue};
+ delete $self->{registered};
+ delete $self->{idents};
+ delete $self->{nick};
+ delete $self->{user};
+ delete $self->{real};
+ delete $self->{server_pass};
+ delete $self->{register_cb_guard};
}
=item $cl->connect ($host, $port)
@@ -374,6 +405,7 @@
user - your username
real - your realname
password - the server password
+ timeout - the TCP connect timeout
All keys, except C<nick> are optional.
@@ -383,7 +415,7 @@
my ($self, $host, $port, $info) = @_;
if (defined $info) {
- $self->reg_cb (
+ $self->{register_cb_guard} = $self->reg_cb (
ext_before_connect => sub {
my ($self, $err) = @_;
@@ -393,12 +425,12 @@
);
}
- $self->unreg_me;
+ delete $self->{register_cb_guard};
}
);
}
- $self->SUPER::connect ($host, $port);
+ $self->SUPER::connect ($host, $port, $info->{timeout});
}
=item $cl->register ($nick, $user, $real, $server_pass)
@@ -648,7 +680,7 @@
$self->send_srv (PING => "AnyEvent::IRC");
$self->{_ping_timer} =
- AnyEvent->timer (after => $int, cb => sub {
+ AE::timer $int, 0, sub {
if ($self->{last_pong_recv} < $self->{last_ping_sent}) {
delete $self->{_ping_timer};
if ($cb) {
@@ -660,7 +692,7 @@
} else {
$self->enable_ping ($int, $cb);
}
- });
+ };
}
=item $cl->lower_case ($str)
@@ -965,14 +997,16 @@
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");
+ $self->dcc_disconnect ($id, "TIMEOUT") if $self;
});
$dcc->{listener} = tcp_server undef, $local_port, sub {
my ($fh, $h, $p) = @_;
- delete $dcc->{listener};
- delete $dcc->{timeout};
+ return unless $dcc && $self;
$dcc->{handle} = AnyEvent::Handle->new (
fh => $fh,
@@ -986,8 +1020,13 @@
$self->event (dcc_accepted => $id, $type, $dcc->{handle});
+ delete $dcc->{listener};
+ delete $dcc->{timeout};
+
}, sub {
my ($fh, $host, $port) = @_;
+ return unless $dcc && $self;
+
$local_ip = $host unless defined $local_ip;
$local_port = $port;
@@ -1037,12 +1076,17 @@
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");
+ $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};
delete $dcc->{connect};
@@ -1212,11 +1256,9 @@
my ($self, $msg) = @_;
if ($self->{registered}) {
- warn "welcome_cb has been called twice!\n";
return;
}
- $self->unreg_me;
$self->{registered} = 1;
$self->event ('registered');
}
@@ -1420,13 +1462,13 @@
my ($self, $msg) = @_;
if ($self->registered) {
- $self->unreg_me;
+ delete $self->{change_nick_cb_guard};
} else {
my $newnick = $self->{nick_change}->($self->nick);
if ($self->lower_case ($newnick) eq $self->lower_case ($self->{nick})) {
- $self->disconnect;
+ $self->disconnect ("couldn't change nick to non-conflicting one");
return 0;
}
@@ -1442,6 +1484,8 @@
$self->channel_remove (undef, $_, [$self->nick]);
$self->event (channel_remove => undef, $_, $self->nick)
}
+
+ $self->cleanup;
}
sub rpl_topic_cb {
Modified: trunk/libanyevent-irc-perl/lib/AnyEvent/IRC/Connection.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libanyevent-irc-perl/lib/AnyEvent/IRC/Connection.pm?rev=45356&op=diff
==============================================================================
--- trunk/libanyevent-irc-perl/lib/AnyEvent/IRC/Connection.pm (original)
+++ trunk/libanyevent-irc-perl/lib/AnyEvent/IRC/Connection.pm Sun Oct 4 16:24:15 2009
@@ -56,13 +56,19 @@
This constructor doesn't take any arguments.
+B<NOTE:> You are free to use the hash member C<heap> (which contains a hash) to
+store any associated data with this object. For example retry timers or
+anything else.
+
+You can also access that member via the C<heap> method.
+
=cut
sub new {
my $this = shift;
my $class = ref($this) || $this;
- my $self = $class->SUPER::new (@_);
+ my $self = $class->SUPER::new (@_, heap => { });
bless $self, $class;
@@ -76,7 +82,7 @@
return $self;
}
-=item $con->connect ($host, $port)
+=item $con->connect ($host, $port [, $prepcb_or_timeout])
Tries to open a socket to the host C<$host> and the port C<$port>.
If an error occurred it will die (use eval to catch the exception).
@@ -84,50 +90,56 @@
If you want to connect via TLS/SSL you have to call the C<enable_ssl>
method before to enable it.
+C<$prepcb_or_timeout> can either be a callback with the semantics of a prepare
+callback for the function C<tcp_connect> in L<AnyEvent::Socket> or a simple
+number which stands for a timeout.
+
=cut
sub connect {
- my ($self, $host, $port) = @_;
-
- $self->{socket}
- and return;
-
- tcp_connect $host, $port, sub {
- my ($fh) = @_;
-
- delete $self->{socket};
-
- unless ($fh) {
- $self->event (connect => $!);
- return;
- }
-
- $self->{host} = $host;
- $self->{port} = $port;
-
- $self->{socket} =
- AnyEvent::Handle->new (
- fh => $fh,
- ($self->{enable_ssl} ? (tls => 'connect') : ()),
- on_eof => sub {
- $self->disconnect ("EOF from server $host:$port");
- },
- on_error => sub {
- $self->disconnect ("error in connection to server $host:$port: $!");
- },
- on_read => sub {
- my ($hdl) = @_;
- $hdl->push_read (line => sub {
- $self->_feed_irc_data ($_[1]);
- });
- },
- on_drain => sub {
- $self->event ('buffer_empty');
- }
- );
-
- $self->event ('connect');
- };
+ my ($self, $host, $port, $prep) = @_;
+
+ if ($self->{socket}) {
+ $self->disconnect ("reconnect requested.");
+ }
+
+ $self->{con_guard} =
+ tcp_connect $host, $port, sub {
+ my ($fh) = @_;
+
+ delete $self->{socket};
+
+ unless ($fh) {
+ $self->event (connect => $!);
+ return;
+ }
+
+ $self->{host} = $host;
+ $self->{port} = $port;
+
+ $self->{socket} =
+ AnyEvent::Handle->new (
+ fh => $fh,
+ ($self->{enable_ssl} ? (tls => 'connect') : ()),
+ on_eof => sub {
+ $self->disconnect ("EOF from server $host:$port");
+ },
+ on_error => sub {
+ $self->disconnect ("error in connection to server $host:$port: $!");
+ },
+ on_read => sub {
+ my ($hdl) = @_;
+ $hdl->push_read (line => sub {
+ $self->_feed_irc_data ($_[1]);
+ });
+ },
+ on_drain => sub {
+ $self->event ('buffer_empty');
+ }
+ );
+
+ $self->event ('connect');
+ }, (defined $prep ? (ref $prep ? $prep : sub { $prep }) : ());
}
=item $con->enable_ssl ()
@@ -150,7 +162,8 @@
sub disconnect {
my ($self, $reason) = @_;
- return unless $self->{socket};
+
+ delete $self->{con_guard};
delete $self->{socket};
$self->event (disconnect => $reason);
}
@@ -169,8 +182,8 @@
=item $con->heap ()
-Returns a hash reference that is local to this connection object
-that lets you store any information you want.
+Returns the hash reference stored in the C<heap> member, that is local to this
+connection object that lets you store any information you want.
=cut
More information about the Pkg-perl-cvs-commits
mailing list