NAME
XAS::Lib::Net::Server - A basic network server for the XAS Environment
SYNOPSIS
my $server = XAS::Lib::Net::Server->new(
-port => 9505,
-host => 'localhost',
-filter => POE::Filter::Line->new(),
-alias => 'server',
-inactivity_timer => 600,
-eol => "\015\012"
}
DESCRIPTION
This module implements a simple text orientated network protocol. Data is sent out as delimited strings. Which means every string has a consistent EOL. These strings may be formatted, such as JSON. This module inherits from XAS::Lib::POE::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 "\015\012";
reaper($wheel)
Called when the inactivity timer is triggered.
process_request($input, $ctx)
This method will process the input from the client. It takes the following parameters:
- $input
-
The input received from the socket.
- $ctx
-
A hash variable to maintain context. This will be initialized with a "wheel" field. Others fields may be added as needed.
process_response($output, $ctx)
This method will process the output for the client. It takes the following parameters:
- $output
-
The output to be sent to the socket.
- $ctx
-
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($errors, $ctx)
This method will process the error output from the client. It takes the following parameters:
- $errors
-
The output to be sent to the socket.
- $ctx
-
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.
handle_connection($wheel)
This method is called after the client connects. This is for additional post connection processing as needed. It takes the following parameters:
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.
SEE ALSO
AUTHOR
Kevin L. Esteb, <kevin@kesteb.us>
COPYRIGHT AND LICENSE
Copyright (c) 2012-2015 Kevin L. Esteb
This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.