| 1 | package XAS::Apps::Test::Echo::Server; | ||
| 2 | |||
| 3 | 1 | our $VERSION = '0.03'; | |
| 4 | |||
| 5 | 1 | ▶ | use XAS::Lib::Net::Server; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | use XAS::Class | ||
| 7 | 1 | debug => 0, | |
| 8 | version => $VERSION, | ||
| 9 | base => 'XAS::Lib::App::Service', | ||
| 10 | accessors => 'port address', | ||
| 11 | vars => { | ||
| 12 | SERVICE_NAME => 'XAS_Echo_Server', | ||
| 13 | SERVICE_DISPLAY_NAME => 'XAS Echo Server', | ||
| 14 | SERVICE_DESCRIPTION => 'This is a test Perl service', | ||
| 15 | } | ||
| 16 | 1 | ▶ | ; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | |||
| 18 | # ---------------------------------------------------------------------- | ||
| 19 | # Public Methods | ||
| 20 | # ---------------------------------------------------------------------- | ||
| 21 | |||
| 22 | sub main { | ||
| 23 | 0 | ▶ | my $self = shift; |
|
Subroutine
main: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 24 | |||
| 25 | 0 | my $server = XAS::Lib::Net::Server->new( | |
| 26 | -alias => 'echo', | ||
| 27 | -port => $self->port, | ||
| 28 | -address => $self->address, | ||
| 29 | ); | ||
| 30 | |||
| 31 | 0 | $self->log->info('Starting up'); | |
| 32 | |||
| 33 | 0 | $self->service->register('echo'); | |
| 34 | 0 | $self->service->run(); | |
| 35 | |||
| 36 | 0 | $self->log->info('Shutting down'); | |
| 37 | |||
| 38 | } | ||
| 39 | |||
| 40 | sub options { | ||
| 41 | 0 | ▶ | my $self = shift; |
|
Subroutine
options: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 42 | |||
| 43 | 0 | $self->{port} = '9505'; | |
| 44 | 0 | $self->{address} = '127.0.0.1'; | |
| 45 | |||
| 46 | return { | ||
| 47 | 'port=s' => \$self->{port}, | ||
| 48 | 'address=s' => \$self->{address}, | ||
| 49 | 0 | }; | |
| 50 | |||
| 51 | } | ||
| 52 | |||
| 53 | # ---------------------------------------------------------------------- | ||
| 54 | # Private Methods | ||
| 55 | # ---------------------------------------------------------------------- | ||
| 56 | |||
| 57 | 1 | 1; | |
| 58 | |||
| 59 | __END__ | ||
| 60 | |||
| 61 | =head1 NAME | ||
| 62 | |||
| 63 | XAS::Apps::Test::Echo::Server - This module is an 'echo' server | ||
| 64 | |||
| 65 | =head1 SYNOPSIS | ||
| 66 | |||
| 67 | use XAS::Apps::Test::Echo::Server; | ||
| 68 | |||
| 69 | my $app = XAS::Apps::Test::Echo::Server->new( | ||
| 70 | -throws => 'something', | ||
| 71 | ); | ||
| 72 | |||
| 73 | exit $app->run(); | ||
| 74 | |||
| 75 | =head1 DESCRIPTION | ||
| 76 | |||
| 77 | This module will 'echo' received messages back to the sender. | ||
| 78 | |||
| 79 | =head1 CONFIGURATION | ||
| 80 | |||
| 81 | There is no additional configuration. | ||
| 82 | |||
| 83 | =head1 OPTIONS | ||
| 84 | |||
| 85 | This module provides these additonal cli options. | ||
| 86 | |||
| 87 | =head2 --port | ||
| 88 | |||
| 89 | The port the server will listen on. Defaults to '9505'. | ||
| 90 | |||
| 91 | =head2 --address | ||
| 92 | |||
| 93 | The address the server will attache too. Defaults to '127.0.0.1'; | ||
| 94 | |||
| 95 | =head1 SEE ALSO | ||
| 96 | |||
| 97 | =over 4 | ||
| 98 | |||
| 99 | =item sbin/echo-server.pl | ||
| 100 | |||
| 101 | =item L<XAS|XAS> | ||
| 102 | |||
| 103 | =back | ||
| 104 | |||
| 105 | =head1 AUTHOR | ||
| 106 | |||
| 107 | Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt> | ||
| 108 | |||
| 109 | =head1 COPYRIGHT AND LICENSE | ||
| 110 | |||
| 111 | Copyright (C) 2012 by Kevin L. Esteb | ||
| 112 | |||
| 113 | This is free software; you can redistribute it and/or modify it under | ||
| 114 | the terms of the Artistic License 2.0. For details, see the full text | ||
| 115 | of the license at http://www.perlfoundation.org/artistic_license_2_0. | ||
| 116 | |||
| 117 | =cut | ||