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
}
DESCRIPTION
This module implements a simple text orientated nework protocol. All "packets" will have an explict "\012\015" appended. These packets may be formated 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.
- -inactivty_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
reaper($wheel)
Called when the inactivity timer is triggered.
declare_events($kernel, $session)
Declare methods to be acted upon.
ACCESSORS
peerport($wheel)
This returns the current port for that wheel.
host($wheel)
This returns the current hostname for that wheel.
client($wheel)
This returns the current client for that wheel.
PUBLIC EVENTS
process_request($kernel, $self, $input, $ctx)
This event will process the input from the client. It takes the following parameters:
- $kernel
-
A handle to the POE kernel.
- $self
-
A handle to the current object.
- $input
-
The input recieved 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($kernel, $self, $output, $ctx)
This event will process the output from the client. It takes the following parameters:
- $kernel
-
A handle to the POE kernel.
- $self
-
A handle to the current object.
- $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($kernel, $self, $output, $ctx)
This event will process the error output from the client. It takes the following parameters:
- $kernel
-
A handle to the POE kernel.
- $self
-
A handle to the current object.
- $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.
SEE ALSO
- POE::Filter::Line
- XAS
AUTHOR
Kevin L. Esteb, <kevin@kesteb.us>
COPYRIGHT AND LICENSE
Copyright (C) 2012 by 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.