Vulcan Logic SRM  

SRM - Documentation


^ SRM Documentation
^ Bananas

- Using Bananas
- Writing Banana components
- The eventloop of Bananas

The eventloop of Bananas

The eventloop of a Banana is intialized by the run() member function. Without this, the Banana will not respond to requests from clients. The eventloop then waits until a request is received from a client calling a function on that object. An event can also be posted by a timer function (currently not implemented).

When an event is posted, the event handler dispatchs it to one of three possible events. These events are: 1. a function is called; 2. the value of a property is requested or 3. the value of a property is set.

Handling function calls

When an function event occurs, the dispatcher calls the member function of the class. In the examples below you can see how a functioncall is used from a client side script. Both the clientside script and Banana are shown.

Example 4-2. Calling a Banana method

<?php
    
/* Make a connection to SRM */
    
$srm = new SRM ('srm.vl-srm.net'7778);
    
$dice = new SRMApp ($srm'Dice');

    
/* Call the roll() function of the Banana */
    
echo $dice->roll();
?>

Example 4-3. Processing a Banana method

<?php
    
/* Class definition */
    
class Dice extends Banana
    
{
        function 
roll() {
            return 
rand (16);
        }
    }

    
/* Start up the Banana */
    
$banana = new Dice;
    
$banana->run();
?>

Prev: Writing Banana components Next: FAQ


© 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by The Vulcan Logic Group