|
NAMEPOE::Component::ControlPort - network control port for POE applicationsSYNOPSISuse POE; use Getopt::Long; use POE::Component::ControlPort; use POE::Component::ControlPort::Command; my @commands = ( { help_text => 'My command', usage => 'my_command [ arg1, arg2 ]', topic => 'custom', name => 'my_command', command => sub { my %input = @_; local @ARGV = @{ $input{args} }; GetOptions( ... ); }, } ); POE::Component::ControlPort->create( local_address => '127.0.0.1', local_port => '31337', # optional... hostname => 'pie.pants.org', appname => 'my perl app', commands => \@commands, poe_debug => 1, ); # other poe sessions or whatever ... POE::Kernel->run(); DESCRIPTIONWhen building network applications, it is often helpful to have a network accessible control and diagnostic interface. This module provides such an interface for POE applications. By default, it provides a fairly limited set of commands but is easily extended to provide whatever command set you require. In addition, if "POE::Component::DebugShell" version 1.018 or above is installed, a set of POE debug commands will be loaded.GETTING STARTEDThe utility of a network accessible controlport is limited only by the commands you allow access to. A controlport with only a status command isn't very useful. Defining commands is easy.DEFINING COMMANDSmy @commands = ( { help_text => 'My command', usage => 'my_command [ arg1, arg2 ]', topic => 'custom', name => 'my_command', command => sub { my %input = @_; local @ARGV = @{ $input{args} }; GetOptions( ... ); }, } ); A command is defined by a hash of metadata and a subroutine reference. The metadata helps to group commands into functional units as well as display help and usage information for the confused user. The meat of a command, obviously, is the subroutine reference which makes up the 'command' part of the metadata. The subroutine reference is executed every time a user issues the command name that is assigned for it. Any text returned from the subroutine will be printed out to the user in the control port. The subroutine's arguments are a hash of data about the command invocation.
LAUNCHING THE PORTPOE::Component::ControlPort->create( local_address => '127.0.0.1', local_port => '31337', # optional... hostname => 'pie.pants.org', appname => 'my perl app', commands => \@commands, poe_debug => 1, ) The "create()" method in the "POE::Component::ControlPort" namespace is used to create and launch the control port. There are several parameters available to "create()".
SHUTTING DOWNThe control port responds to a "shutdown" event to the appname given during control port creation. This event will cause the immediate shutdown of all connections and the termination of the listener.REQUIREMENTSThe following perl modules are required for this module to work properly.
AUTHORMatt Cashner (sungo@pobox.com)REVISION$Rev: 266 $DATE$Date: 2004-05-09 22:59:17 -0400 (Sun, 09 May 2004) $LICENSECopyright (c) 2004, Matt CashnerPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Visit the GSP FreeBSD Man Page Interface. |