Hoppy::TCPHandler::Disconnected - TCP handler class that will be used when client disconnected.


Hoppy documentation Contained in the Hoppy distribution.

Index


Code Index:

NAME

Top

Hoppy::TCPHandler::Disconnected - TCP handler class that will be used when client disconnected.

SYNOPSIS

Top

DESCRIPTION

Top

TCP handler class that will be used when client disconnected.

METHODS

Top

do_handle($poe)

AUTHOR

Top

Takeshi Miki <miki@cpan.org>

LICENSE

Top

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Top


Hoppy documentation Contained in the Hoppy distribution.

package Hoppy::TCPHandler::Disconnected;
use strict;
use warnings;
use base qw( Hoppy::Base );

sub do_handle {
    my $self       = shift;
    my $poe        = shift;
    my $c          = $self->context;
    my $session_id = $poe->session->ID;
    my $user       = $c->room->fetch_user_from_session_id($session_id);
    my $user_id;
    if ($user) {
        $user_id = $user->user_id;
        $c->room->logout( { user_id => $user_id }, $poe );
    }
    delete $c->{sessions}->{$session_id};
    delete $c->{not_authorized}->{$session_id};
    $poe->kernel->yield("shutdown");
    if ( my $hook = $c->hook->{client_disconnected} ) {
        $hook->work( { poe => $poe, user_id => $user_id } );
    }
}

1;
__END__