Acme-Sort-Sleep
view release on metacpan or search on metacpan
local/lib/perl5/IO/Async/Protocol.pm view on Meta::CPAN
my $loop = $self->loop or croak "Cannot ->connect a ".ref($self)." that is not in a Loop";
$loop->connect(
%args,
socktype => "stream",
$on_transport => sub {
my ( $transport ) = @_;
$self->configure( transport => $transport );
$on_connected->( $self ) if $on_connected;
},
);
}
=head1 TRANSPORT DELEGATION
The following methods are delegated to the transport object
close
=cut
sub close { shift->transport->close }
=head1 SUBCLASS METHODS
C<IO::Async::Protocol> is a base class provided so that specific subclasses of
it provide more specific behaviour. The base class provides a number of
methods that subclasses may wish to override.
If a subclass implements any of these, be sure to invoke the superclass method
at some point within the code.
=cut
=head2 setup_transport
$protocol->setup_transport( $transport )
Called by C<configure> when a new C<transport> object is given, this method
should perform whatever setup is required to wire the new transport object
into the protocol object; typically by setting up event handlers.
=cut
sub setup_transport
{
my $self = shift;
my ( $transport ) = @_;
$transport->configure(
on_closed => $self->_capture_weakself( sub {
my $self = shift or return;
my ( $transport ) = @_;
$self->maybe_invoke_event( on_closed => );
$self->configure( transport => undef );
} ),
);
}
=head2 teardown_transport
$protocol->teardown_transport( $transport )
The reverse of C<setup_transport>; called by C<configure> when a previously
set-up transport object is about to be replaced.
=cut
sub teardown_transport
{
my $self = shift;
my ( $transport ) = @_;
$transport->configure(
on_closed => undef,
);
}
=head1 AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
=cut
0x55AA;
( run in 1.650 second using v1.01-cache-2.11-cpan-d80b1682f3f )