Skip to content

Commit

Permalink
Merge pull request #15 from nkukard/tcp-server-component-stopped-event
Browse files Browse the repository at this point in the history
Added support for Stopped callback in TCP server.
  • Loading branch information
rcaputo committed Nov 26, 2013
2 parents d3cb2fb + af5deb2 commit ebc911e
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lib/POE/Component/Server/TCP.pm
Expand Up @@ -116,6 +116,7 @@ sub new {
my $session_type = delete $param{SessionType};
my $session_params = delete $param{SessionParams};
my $server_started = delete $param{Started};
my $server_stopped = delete $param{Stopped};
my $listener_args = delete $param{ListenerArgs};

$listener_args = [] unless defined $listener_args;
Expand Down Expand Up @@ -541,6 +542,7 @@ sub new {
# Dummy states to prevent warnings.
_stop => sub {
DEBUG and warn "$$: $_[HEAP]->{alias} _stop";
$server_stopped and $server_stopped->(@_);
undef($accept_session_id);
return 0;
},
Expand Down Expand Up @@ -726,6 +728,10 @@ set to a copy of the values in the server's C<ListenerArgs>
constructor parameter. The other parameters are standard for
POE::Session's _start handlers.
The component's C<Stopped> callback is invoked at the beginning of the
master session's _stop routine. The parameters are standard for
POE::Session's _stop handlers.
The component's C<Error> callback is invoked when the server has a
problem listening for connections. C<Error> may also be called if the
component's default acceptor has trouble accepting a connection.
Expand Down Expand Up @@ -1009,7 +1015,8 @@ will not reach these handlers.
If POE::Kernel::ASSERT_USAGE is enabled, the constructor will croak() if it
detects a state that it uses internally. For example, please use the "Started"
callback if you want to specify your own "_start" event.
and "Stopped" callbacks if you want to specify your own "_start" and "_stop"
events respectively.
=head4 ObjectStates
Expand All @@ -1023,7 +1030,8 @@ will not reach these handlers.
If POE::Kernel::ASSERT_USAGE is enabled, the constructor will croak() if it
detects a state that it uses internally. For example, please use the "Started"
callback if you want to specify your own "_start" event.
and "Stopped" callbacks if you want to specify your own "_start" and "_stop"
events respectively.
=head4 PackageStates
Expand All @@ -1038,7 +1046,8 @@ will not reach these handlers.
If POE::Kernel::ASSERT_USAGE is enabled, the constructor will croak() if it
detects a state that it uses internally. For example, please use the "Started"
callback if you want to specify your own "_start" event.
and "Stopped" callbacks if you want to specify your own "_start" and "_stop"
events respectively.
=head4 Port
Expand All @@ -1057,6 +1066,13 @@ main server session's context. It notifies the server that it has
fully started. The callback's parameters are the usual for a
session's _start handler.
=head4 Stopped
C<Stopped> sets an optional callback that will be invoked within the
main server session's context. It notifies the server that it has
fully stopped. The callback's parameters are the usual for a
session's _stop handler.
=head4 ListenerArgs
C<ListenerArgs> is passed to the listener session as the C<args> parameter. In
Expand Down

0 comments on commit ebc911e

Please sign in to comment.