FLAP - Flash Remoting in Perl

To use Flash::FLAP, download it and install in the usual way (perl Makefile.PL; make; make install).


Sample code to use Flash Remoting


Client code:

//Obligatory includes
#include "NetServices.as"
#include "NetDebug.as"

//Get a connection object
NetServices.setDefaultGatewayURL("http://host/cpu.pl");
connection = NetServices.createGatewayConnection();

//Get a pointer to a service
remoteService = connection.getService("Foo", this);

//Call a remote method on that service
remoteService.bar();

//or... send arguments to the server:
remoteService.bar(arg1, arg2);

//This callback function will be invoked
function bar_result(value)
{
//do something with the value
}
 
Server code, option A - service registration.
Use in simple applications.
use Flash::FLAP;

package Foo;

sub new
{
my ($proto)=@_;
my $self={};
bless $self, $proto;
Server code A:

use Flash::FLAP;

package Foo;

sub new
{
my ($proto)=@_;
my $self={};
bless $self, $proto;
return $self;
}

sub bar
{
my ($self, $arg1, $arg2) = @_;
my $value;

#Compute a return value
#...

return $value;
}

#Create the gateway object
my $gateway = Flash::FLAP->new;

#Register a service that provides methods.
#You can register more than one service.
#This can happen during server startup (if running under mod_perl).
$gateway->registerService("Foo",new Foo());

#Let the gateway figure out who will be called.
$gateway->service();

Server code, option B - limited service discovery.
Use in complex applications.

Part 1.  The gateway script.

use Flash::FLAP;


#Create the gateway object

my $gateway = Flash::FLAP->new;

#Set a directory that will contain Perl package.
#Each package will correspond to one service -
#there can be as many as you want!
#You can set only one class path, though.

$gateway->setBaseClassPath("./basicservices/");

#Let the gateway figure out who will be called.

$gateway->service();



Part 2.  Sample class in the registered directory.

package DataEcho;

sub new
{
my ($proto)=@_;
my $self={};
bless $self, $proto;
return $self;
}


sub methodTable
{
return {
"echoNormal" => {
"description" => "Echoes the passed argument back to Flash (no need to set the return t
ype)",
"access" => "remote", # available values are private, public, remote
},
"echoDate" => {
"description" => "Echoes a Flash Date Object (the returnType needs setting)",
"access" => "remote", # available values are private, public, remote
"returns" => "date"
},
"echoXML" => {
"description" => "Echoes a Flash XML Object (the returnType needs setting)",
"access" => "private", # available values are private, public, remote
"returns" => "xml"
}
};
}

sub echoNormal
{
my ($self, $data) = @_;
return $data;
}
sub echoDate
{
my ($self, $data) = @_;
return $data;
}
sub echoXML
{
my ($self, $data) = @_;
return $data;
}

1;