NAME

Distributed::Process::Interface - a base class for handling a network connection and the commands received from it.

DESCRIPTION

Methods

command_handlers

Returns a list of lists defining patterns against which to try and match a line, and what to do if a line matches it.

Subclasses may overload this class to enable other commands:

    sub command_handlers {
	my $self = shift;
	my @c = $self->SUPER::command_handlers();
	push @c, [ qr/regex/, sub { 'what to do with line' . $_[0] }, 'test' ];
	push @c, [ qr/^another/i, sub { $self->do_something(@_) }, 'another test' ];
    }

The first item in each array ref is a regular expression, against which the lines coming in through the input stream will be matched. When a match is found, the second item is used.

If the second item is a string, it is sent back, i.e., printed to the output stream. If is a coderef, that coderef is executed, passing it the incoming line. The list of values returned by the coderef are sent to the output stream.

The third item is optional and will be used in debugging messages to identify which regular expression is being used.

handle_line LIST

Compares a line with the patterns returned by command_handlers() and, if the pattern matches, run the corresponding callback or returns the corresponding string. Once a pattern has matched, handle_line() returns and the remaining patterns are not checked.

The callbacks are invoked with the full LIST of arguments to handle_line(), although only the first argument is matched against the regular expression.

Returns undef if no pattern could match.

send LIST

Prints each string in LIST with a CR+LF sequence to the output stream.

Attributes

The following list describes the attributes of this class. They must only be accessed through their accessors. When called with an argument, the accessor methods set their attribute's value to that argument and return its former value. When called without arguments, they return the current value.

server

The P::D::Server under which the Interface is running.

handle
in_handle

The IO::Handle object that represents the input stream.

out_handle

The IO::Handle object that represents the output stream.

SEE ALSO

Distributed::Process::Server, Distributed::Process::Client, Distributed::Process::Master, Distributed::Process::RemoteWorker

AUTHOR

Cédric Bouvier, <cbouvi@cpan.org>

BUGS

Please report any bugs or feature requests to bug-distributed-process@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Copyright 2005 Cédric Bouvier, All Rights Reserved.

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

1 POD Error

The following errors were encountered while parsing the POD:

Around line 171:

Non-ASCII character seen before =encoding in 'Cédric'. Assuming CP1252