NAME
Net::MessageBus::Server - Pure Perl message bus server
VERSION
Version 0.08
SYNOPSIS
This module creates a new Net::MessageBus server running on the specified address/port
Usage :
use Net::MessageBus::Server;
my $MBServer = Net::MessageBus::Server->new(
address => '127.0.0.1',
port => '15000',
logger => $logger,
authenticate => \&authenticate_method,
);
$MBServer->start();
or
$MBServer->daemon() || die "Fork to start Net::MessageBus::Server in background failed!"
...
if ( $MBServer->is_running() ) {
print "Server is alive";
}
...
$MBServer->stop(); #if started as a daemon.
SUBROUTINES/METHODS
new
Creates a new server object. It does not automatically start the server, you have to start it using the start() method.
Arguments :
address = The address on which the server should bind , 127.0.0.1 by dafault
port = The port on which the server should listen , 4500 by default
logger Any object that supports the fallowing methods : debug, info, warn,error
authenticate = A code ref to a method that returns true if the authentication is successfull and false otherwise
Example
my $MBServer = Net::MessageBus::Server->new(
address => '127.0.0.1',
port => '15000',
logger => $logger,
authenticate => \&authenticate_method,
);
Example authentication method :
sub authenticate_method {
my ($username, $password, $client_ip) = @_;
return 1 if ($username eq "john" && $password eq "1234");
return 0;
}
start
Starts the server
daemon
Starts the server in background
stop
Stops a previously started daemon
is_running
Returns true if the server process is running
Private methods
create_server_socket
Starts the TCP socket that to which the clients will connect
get_peer_address
Returns the ip address for the given connection
subscribe_client
Adds the client to the subscription list which he specified
unsubscribe_client
Removes the given socket from all subscription lists
clients_registered_for_message
Returns a list containing all the file handles registered to receive the given message
send_message
Sends the given message to the clients that subscribed to the group or sender of the messages
AUTHOR
Horea Gligan, <gliganh at gmail.com>
BUGS
Please report any bugs or feature requests to bug-net-MessageBus at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-MessageBus. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Net::MessageBus::Server
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2012 Horea Gligan.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.