Gligan Calin Horea > Net-MessageBus > Net::MessageBus::Server

Download:
Net-MessageBus-0.08.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.08   Source  

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 :

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:

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.

syntax highlighting: