MooX-Async-Console

 view release on metacpan or  search on metacpan

lib/MooX/Async/Console/TCP.pm  view on Meta::CPAN

package MooX::Async::Console::TCP;

=head1 NAME

MooX::Async::Console::TCP - A TCP framing module for MooX::Async::Console

=head1 SYNOPSIS

See L<MooX::Async::Console>

=head1 DESCRIPTION

A L<IO::Async::Listener> subclass which listens on a TCP port. Each
connection is created as a L<MooX::Async::Console::TCPClient> module
which interpets the byte stream and invokes L</on_command> when a
command is ready to be executed.

=head1 BUGS

Certainly.

=cut

use Modern::Perl '2017';
use strictures 2;

use Moo;
use Future;
use MooX::Async;
use MooX::Async::Console::TCPClient;
use Scalar::Util  qw(blessed);
use namespace::clean;

extends MooXAsync('Listener');

with 'MooX::Role::Logger';

=head1 PUBLIC INTERFACE

=head2 ATTRIBUTES

=over

=item address (default: C<127.0.0.1>)

The IP address to listen for connections on.

=item port (default: C<$ENV{MXACPORT} // 0>)

The TCP port to listen for connections on. The default is 0 which lets
the kernel select a port. The value in this attribute is updated when
the socket is bound.

=back

=cut

has address => is => ro  => default => '127.0.0.1';
has port    => is => rwp => default => ($ENV{MXACPORT} // 0);

=head2 EVENTS

=over

=item on_command

Must be included in the constuctor. Invoked by this module to execute
a command. This interface is described in
L<MooX::Async::Console/on_command>.

Arguments:

=over

=item command

Name of the command to execute.

=item inform

Coderef with which the command can send messages over the connection.

=item args



( run in 0.874 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )