Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

POE::Component::AI::MegaHAL
A non-blocking wrapper around AI::MegaHAL.

POE::Component::AI::MegaHAL - A non-blocking wrapper around AI::MegaHAL.


NAME

POE::Component::AI::MegaHAL - A non-blocking wrapper around AI::MegaHAL.


SYNOPSIS


    use POE qw(Component::AI::MegaHAL);

    my $poco = POE::Component::AI::MegaHAL->spawn( autosave => 1, debug => 0, 

                                                   path => '.', options => { trace => 1 } );

    POE::Session->create(

        package_states => [

                'main' => [ qw(_start _got_reply) ],

        ],

    );

    $poe_kernel->run();

    exit 0;

    sub _start {

        $_[KERNEL]->post( $poco->session_id() => do_reply => { text => 'What is a MegaHAL ?', event => '_got_reply' } );

        undef;

    }

    sub _got_reply {

        print STDOUT $_[ARG0]->{reply} . "\n";

        $_[KERNEL]->post( $poco->session_id() => 'shutdown' );

        undef;

    }


DESCRIPTION

POE::Component::AI::MegaHAL provides a non-blocking wrapper around the AI::MegaHAL manpage.


METHODS

spawn
Accepts a number of arguments:

  'autosave' and 'path' are passed to AI::MegaHAL; 

  'debug' sets the debug mode;

  'options' is a hashref of parameters to pass to the component's POE::Session; 

  'alias', is supported for using POE::Kernel aliases;

session_id
Returns the component session id.


INPUT

These are the events that we'll accept.

All megahal related events accept a hashref as the first parameter. You must specify 'event' as the event in your session where you want the response to go. See the example in the SYNOPSIS.

The 'shutdown' event doesn't require any parameters.

intial_greeting
Solicits the initial greeting returned by the brain on start-up.

do_reply
Submits text to the brain and solicits a reply. In the hashref you must specify 'text' with the data you wish to submit to the the AI::MegaHAL manpage object.

_cleanup
Saves the megahal brain to file.

shutdown
Shuts the component down gracefully. Any pending requests will be serviced and return events dispatched.


OUTPUT

Events generated by the component in response to the above input will have a hashref as ARG0. $hashref->{reply} will contain the applicable response from the brain.


AUTHOR

Chris 'BinGOs' Williams

with contributions by David Davies <xantus>.


SEE ALSO

the AI::MegaHAL manpage

http://megahal.sourceforge.net/

POE

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy