At

 view release on metacpan or  search on metacpan

eg/mojo_oauth.pl  view on Meta::CPAN

    catch ($e) {
        $c->app->log->error( 'Failed to fetch profile: ' . $e );
        return $c->render( text => 'Authenticated, but failed to fetch profile: ' . $@, status => 500 );
    }
    say '   Display Name: ' . $profile->{displayName};
    say '   Description:  ' . ( $profile->{description} // '[no description]' );
    $c->render( text => '<h1>Success!</h1><p>You are authenticated as <b>' .
            $profile->{displayName} . '</b>.</p><p>You can close this window and check the console.</p>' );

    # Gracefully stop the server
    Mojo::IOLoop->timer( 1 => sub { exit 0 } );
};
app->start( 'daemon', '-l', 'http://127.0.0.1:' . $port );

=head1 NAME

mojo_oauth.pl - OAuth Authentication Example Using Mojolicious

=head1 SYNOPSIS

    perl eg/mojo_oauth.pl

lib/At/UserAgent.pm  view on Meta::CPAN

                    20 => sub {
                        return unless $tx;
                        $tx->send( [ 1, 0, 0, 0, 9, '' ] );    # Raw Ping frame
                    }
                );

                # Activity watchdog: if we don't get a message for 10 seconds, close and reconnect
                my $watchdog;
                my $reset_watchdog = sub {
                    Mojo::IOLoop->remove($watchdog) if defined $watchdog;
                    $watchdog = Mojo::IOLoop->timer(
                        10 => sub {
                            $tx->finish( 4000, "Watchdog timeout" );
                        }
                    );
                };
                $reset_watchdog->();
                $tx->on(
                    message => sub ( $tx, $msg ) {
                        $reset_watchdog->();
                        $cb->( $msg, undef );



( run in 2.510 seconds using v1.01-cache-2.11-cpan-adec679a428 )