NAME
XAS::Lib::Net::Server - A basic network server for the XAS Environment
SYNOPSIS
my $server = XAS::Lib::Net::Server->new(
-port => 9505,
-address => 'localhost',
-filter => POE::Filter::Line->new(),
-alias => 'server',
-inactivity_timer => 600,
-eol => "\012\015"
}
DESCRIPTION
This module implements a simple text orientated network protocol. Data is sent out as "packets". Which means everything is delimited with a consistent EOL. These packets may be formatted strings, such as JSON. This module inherits from XAS::Lib::Session.
METHODS
new
This initializes the module and starts listening for requests. There are five parameters that can be passed. They are the following:
- -alias
-
The name of the POE session.
- -port
-
The IP port to listen on.
- -address
-
The address to bind too.
- -inactivity_timer
-
Sets an inactivity timer on clients. When it is surpassed, the method reaper() is called with the POE wheel id. What reaper() does is application specific. The default is 600 seconds.
- -filter
-
An optional filter to use, defaults to POE::Filter::Line
- -eol
-
An optional EOL, defaults to "\012\015";
reaper($wheel)
Called when the inactivity timer is triggered.
ACCESSORS
peerport($wheel)
This returns the current port for that wheel.
host($wheel)
This returns the current host name for that wheel.
client($wheel)
This returns the current client for that wheel.
PUBLIC EVENTS
process_request(OBJECT, ARG0, ARG1)
This event will process the input from the client. It takes the following parameters:
- OBJECT
-
A handle to the current object.
- ARG0
-
The input received from the socket.
- ARG1
-
A hash variable to maintain context. This will be initialized with a "wheel" field. Others fields may be added as needed.
process_response(OBJECT, ARG0, ARG1)
This event will process the output from the client. It takes the following parameters:
- OBJECT
-
A handle to the current object.
- ARG0
-
The output to be sent to the socket.
- ARG1
-
A hash variable to maintain context. This uses the "wheel" field to direct output to the correct socket. Others fields may have been added as needed.
process_errors(OBJECT, ARG0, ARG1)
This event will process the error output from the client. It takes the following parameters:
- OBJECT
-
A handle to the current object.
- ARG0
-
The output to be sent to the socket.
- ARG1
-
A hash variable to maintain context. This uses the "wheel" field to direct output to the correct socket. Others fields may have been added as needed.
SEE ALSO
- POE::Filter::Line
- XAS
AUTHOR
Kevin L. Esteb, <kevin@kesteb.us>
COPYRIGHT AND LICENSE
Copyright (C) 2014 Kevin L. Esteb
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
See http://dev.perl.org/licenses/ for more information.