NAME
XAS::Lib::Net::POE::Client - An asynchronous network client based on POE
SYNOPSIS
This module is a class used to create network clients.
package Client;
use POE;
use XAS::Class
version => '1.0',
base => 'XAS::Lib::Net::POE::Client'
;
sub handle_connection {
my ($self) = @_[OBJECT];
my $packet = "hello!";
$poe_kernel->yield('write_data', $packet);
}
DESCRIPTION
This module handles the nitty-gritty details of setting up the communications channel to a server. You will need to sub-class this module with your own for it to be useful.
An attempt to maintain that channel will be made when/if that server should happen to disappear off the network. There is nothing more unpleasant then having to go around to dozens of servers and restarting processes.
METHODS
new
This method initializes the class and starts a session to handle the communications channel. It takes the following parameters:
- -alias
-
The session alias, defaults to 'client'.
- -server
-
The servers host name.
- -port
-
The servers port number.
- -retry_count
-
Wither to attempt reconnections after they run out. Defaults to true.
- -tcp_keepalive
-
For those pesky firewalls, defaults to false
read_data
This event is triggered when data is received for the server.
write_data
You use this event to send data to the server.
handle_connection
This event is triggered upon initial connection to the server.
connection_down
This event is triggered to allow you to be notified if the connection to the server is currently down.
connection_up
This event is triggered to allow you to be notified when the connection to the server is restored.
SEE ALSO
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.