AnyEvent-MockTCPServer
view release on metacpan or search on metacpan
lib/AnyEvent/MockTCPServer.pm view on Meta::CPAN
=item C<port>
The port that the server should listen on. Default is to pick a
free port.
=item C<timeout>
The timeout for IO operations in seconds. Default is 2 seconds.
=item C<on_timeout>
The callback to call when a timeout occurs. Default is to die
with message C<"server timeout\n">.
=back
=head2 C<listening()>
Condvar that is notified when the mock server is ready. The value
received is an array reference containing the address and port that
the server is listening on.
=head2 C<connect_address()>
An array reference containing the address and port that the server is
listening on. This method blocks on the L</listening()> condvar until
the server is listening.
=head2 C<connect_host()>
The address that the server is listening on. This method blocks on
the L</listening()> condvar until the server is listening.
=head2 C<connect_port()>
The port that the server is listening on. This method blocks on
the L</listening()> condvar until the server is listening.
=head2 C<connect_string()>
A string containing the address and port that the server is listening
on separated by a colon, 'C<:>'. This method blocks on the
L</listening()> condvar until the server is listening.
=head2 C<finished_cv()>
Condvar that is notified when the mock server has completed processing
of all the expected connections.
=head2 C<next_action($handle, $actions)>
Internal method called by the action methods when the server should
proceed with the next action. Must be called by any action methods
written in subclasses of this class.
=head1 ACTION METHOD ARGUMENTS
These methods (and methods added by derived classes) can be used in
action lists passed via the constructor C<connections> parameter. The
C<$handle> and C<$actions> arguments should be omitted from the action
lists as they are supplied by the framework.
=head1 ACTION METHODS
=head2 C<send($handle, $actions, $send, $desc)>
Sends the payload, C<$send>, to the client.
=head2 C<packsend($handle, $actions, $send, $desc)>
Sends the payload, C<$send>, to the client after removing whitespace
and packing it with 'H*'. This method is equivalent to the
L</send($handle, $actions, $send, $desc)> method when passed the
packed string but debug messages contain the unpacked strings are
easier to read.
=head2 C<recv($handle, $actions, $expect, $desc)>
Waits for the data C<$expect> from the client.
=head2 C<recvline($handle, $actions, $expect, $desc)>
Waits for a line of data C<$expect> from the client. See
L<AnyEvent::Handle> for the definition of 'line'.
=head2 C<packrecv($handle, $actions, $expect, $desc)>
Removes whitespace and packs the string C<$expect> with 'H*' and then
waits for the resulting data from the client. This method is
equivalent to the L</recv($handle, $actions, $expect, $desc)> method
when passed the packed string but debug messages contain the unpacked
strings are easier to read.
=head2 C<sleep($handle, $actions, $interval, $desc)>
Causes the server to sleep for C<$interval> seconds.
=head2 C<code($handle, $actions, $code, $desc)>
Causes the server to execute the code reference with the client handle
as the first argument.
=head1 AUTHOR
Mark Hindess <soft-cpan@temporalanomaly.com>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2014, 2017 by Mark Hindess.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 1.965 second using v1.01-cache-2.11-cpan-5b529ec07f3 )