Skip Menu |

This queue is for tickets about the POE CPAN distribution.

Report information
The Basics
Id: 1691
Status: resolved
Priority: 0/
Queue: POE

People
Owner: Nobody in particular
Requestors: perl [...] bogleg.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.23
Fixed in: (no value)



Subject: add a _start callback to PoCo::Client::TCP
This patch applies cleanly after my patch in http://rt.cpan.org/NoAuth/Bug.html?id=1682 It adds a named parameter Start which is a coderef to call at the end of PoCo::Client::TCP's _start event handler just prior to $kernel->yield('reconnect').
--- TCP.pm 2002-10-18 17:26:18.000000000 -0500 +++ .cpan/build/POE-0.23/POE/Component/Client/TCP.pm 2002-10-18 17:23:25.000000000 -0500 @@ -48,7 +48,7 @@ my $bind_port = delete $param{BindPort}; my $ctimeout = delete $param{ConnectTimeout}; - foreach ( qw( Connected ConnectError Disconnected ServerInput + foreach ( qw( Start Connected ConnectError Disconnected ServerInput ServerError ServerFlushed ) ) { @@ -56,6 +56,7 @@ if defined($param{$_}) and ref($param{$_}) ne 'CODE'; } + my $start_callback = delete $param{Start}; my $conn_callback = delete $param{Connected}; my $conn_error_callback = delete $param{ConnectError}; my $disc_callback = delete $param{Disconnected}; @@ -116,6 +117,7 @@ my ($kernel, $heap) = @_[KERNEL, HEAP]; $heap->{shutdown_on_error} = 1; $kernel->alias_set( $alias ) if defined $alias; + $start_callback->(@_) if defined $start_callback; $kernel->yield( 'reconnect' ); }, @@ -287,6 +289,8 @@ Domain => AF_INET, # Optional. ConnectTimeout => 5, # Seconds; optional. + Start => \&start_callback, + Connected => \&handle_connect, ConnectError => \&handle_connect_error, Disconnected => \&handle_disconnect, @@ -304,6 +308,10 @@ # Sample callbacks. + sub start_callback { + # no special parameters + } + sub handle_connect { my ($socket, $peer_address, $peer_port) = @_[ARG0, ARG1, ARG2]; } @@ -474,6 +482,11 @@ RemotePort contains the port to connect to. It is required and may be a service name ("echo") or number (7). +=item Start + +Start is an optional callback that is called prior to any connection +attempts. + =item ServerError ServerError is an optional callback to notify a program that an
Added as Started. Also included Args, which lets you pass parameters to Started's function.