Net::MessageBus::Server - Pure Perl message bus server
Version 0.08
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.
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; }
Starts the server
Starts the server in background
Stops a previously started daemon
Returns true if the server process is running
Starts the TCP socket that to which the clients will connect
Returns the ip address for the given connection
Adds the client to the subscription list which he specified
Removes the given socket from all subscription lists
Returns a list containing all the file handles registered to receive the given message
Sends the given message to the clients that subscribed to the group or sender of the messages
Horea Gligan, <gliganh at gmail.com>
<gliganh at gmail.com>
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.
bug-net-MessageBus at rt.cpan.org
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)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-MessageBus
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Net-MessageBus
CPAN Ratings
http://cpanratings.perl.org/d/Net-MessageBus
Search CPAN
http://search.cpan.org/dist/Net-MessageBus/
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.
To install Net::MessageBus, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::MessageBus
CPAN shell
perl -MCPAN -e shell install Net::MessageBus
For more information on module installation, please visit the detailed CPAN module installation guide.