AMF-Perl

 view release on metacpan or  search on metacpan

doc/code.html  view on Meta::CPAN

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="content-type"
 content="text/html; charset=ISO-8859-1">
  <title>AMF::Perl - Flash Remoting in Perl and Python</title>
  <style>
body {  
	scrollbar-3d-light-color:		#000000; 
	scrollbar-arrow-color:			#000066; 
	scrollbar-base-color:			#003366; 
	scrollbar-dark-shadow-color:	#FFFFFF; 
	scrollbar-face-color:			#003366; 
	scrollbar-highlight-color:		#FFFFFF; 
	scrollbar-shadow-color:			#000000;

doc/code.html  view on Meta::CPAN

<a href=encoding.html>Read this</a> if you want to send and receive strings in non-English encodings.
      <br><br>
Client code:<br>
      <br>
<textarea cols=50 rows=30>
//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);

doc/code.html  view on Meta::CPAN

use AMF::Perl;


#Create the gateway object

my $gateway = AMF::Perl-&gt;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-&gt;setBaseClassPath("./basicservices/");

#Let the gateway figure out who will be called.

$gateway-&gt;service();
</textarea>

</td>
<td valign=top>
<textarea cols=50 rows=20>
#!/usr/bin/python

from AMF import AMF
import sys
import os

gateway = AMF.AMF()

gateway.setRelativeBaseClassPath("/basicservices")

gateway.service()
</textarea>
</td></tr></table>
<br>
<h3>Part 2.&nbsp; Sample class in the registered directory.</h3>
<table>
<tr><th>Perl</th><th>Python</th></tr>
    <tr>
<td valign=top>

doc/code.html  view on Meta::CPAN

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

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

1;
</textarea>
</td>
<td valign=top>

doc/code.html  view on Meta::CPAN


    def echoDate(self, arg):
        return arg

    def echoXML(self, arg):
        return arg

    def methodTable(self):
        table = {}
        table["echoNormal"]= {
                    "description" : "Echoes the passed argument back to Flash (no need to set the return type)",
                    "access" : "remote", # available values are private, public, remote
            }
        table["echoDate"] = {
                    "description" : "Echoes a Flash Date Object (the returnType needs setting)",
                    "access" : "remote", # available values are private, public, remote
                    "returns" : "date"
            }
        table["echoXML"] = {
                    "description" : "Echoes a Flash XML Object (the returnType needs setting)",
                    "access" : "private", # available values are private, public, remote
                    "returns" : "xml"
            }
        return table
</textarea>
</td></tr></table>

      </td>
    </tr>
  </tbody>

doc/cpu.pl  view on Meta::CPAN


use strict;

=head1 COMMENT
        
    ActionScript for this service:

    #include "NetServices.as"
    #include "NetDebug.as"

    conn = NetServices.setDefaultGatewayURL("http:#host/cpu.pl");
    conn = NetServices.createGatewayConnection();

    connection = NetServices.createGatewayConnection();

    remoteService = connection.getService("CpuUsage", this);

    remoteService.getCpuUsage();
=cut

use AMF::Perl;

doc/encoding.html  view on Meta::CPAN

<h2>Using non-standard encoding</h2>
Kostas Chatzikokolakis submitted a patch with the following explanation:
<br>
All data in flash remoting are sent as unicode. However, database data
and scripts are usually in a local encoding. I made some enhacements to
AMF::Perl so that it automatically converts all strings to utf8 when sending
and back to the given encoding when receiving. The usage is:
<pre>
my $gateway = new AMF::Perl;
$gateway->encoding("iso-8859-7");
$gateway->setBaseClassPath("Services/");
$gateway->service();
</pre>

<a href=index.html>Go back to the AMF::Perl documentation</a>

doc/examples/basic/basic.pl  view on Meta::CPAN

#This is a server-side script that responds to an Macromedia Flash client
#talking in ActionScript. See the AMF::Perl project site (http://www.simonf.com/amfperl)
#for more information.

#You have to copy the directory "basicservices" into the same directory as this script.

use strict;
use AMF::Perl;

my $gateway = AMF::Perl->new;
$gateway->setBaseClassPath("./basicservices/");
$gateway->service();

doc/examples/basic/basicservices/DataEcho.pm  view on Meta::CPAN

    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 type)",
            "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" => "remote", # available values are private, public, remote
            "returns" => "xml"
        },
        "generateError" => {
            "description" => "Throw an error so that _status, not _result on the client side is called",
            "access" => "remote", # available values are private, public, remote
        },
    };
}

doc/examples/cpu/cpu.pl  view on Meta::CPAN


use strict;

=head1 COMMENT
        
        ActionScript for this service:

        #include "NetServices.as"
        #include "NetDebug.as"

        NetServices.setDefaultGatewayURL("http://host/cpu.pl");

        connection = NetServices.createGatewayConnection();

        remoteService = connection.getService("CpuUsage", this);

        remoteService.getCpuUsage();
=cut

use AMF::Perl;

doc/examples/dataGrid/dataGrid.pl  view on Meta::CPAN

use strict;
use lib '/var/www/libperl';

=head1 COMMENT
        
    ActionScript for this service:

    #include "NetServices.as"
    #include "NetDebug.as"

    conn = NetServices.setDefaultGatewayURL("http:#host/cpu.pl");
    conn = NetServices.createGatewayConnection();

    connection = NetServices.createGatewayConnection();

    remoteService = connection.getService("CpuUsage", this);

    remoteService.getCpuUsage();
=cut

use AMF::Perl;

doc/examples/petmarket/README.txt  view on Meta::CPAN


http://www.simonf.com/amfperl/examples/petmarket/index.html

(Unlike other examples, the client is NOT included into the AMF::Perl distribution due to its size.)

2. Usage.

You need to load the data in petmarket.sql into a database and configure
the database server, name username and password in dbConn.pm.

You HAVE to set your server URL in initFunction/mainInit.as and then recompile main.fla in order to point your
client to your server.

3. Notes about implementation.

You HAVE to have these files in the directory petmarket/api relative to your Perl gateway script,
because this is what the Flash client assumes.

doc/examples/petmarket/petmarket.pl  view on Meta::CPAN

# The code is based on the -PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client
#talking in ActionScript. See the AMF::Perl project site (http://www.simonf.com/amfperl)
#for more information.

use strict;
use AMF::Perl;

my $gateway = AMF::Perl->new;
$gateway->setBaseClassPath(".");
$gateway->debugDir("/tmp");
$gateway->service();

doc/examples/petmarket/petmarket/api/dbConn.pm  view on Meta::CPAN

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

    my $dbh = DBI->connect("DBI:mysql:host=$dbhost:db=$dbname","$dbuser","$dbpass",{ PrintError=>1, RaiseError=>1 }) or die "Unable to connect: " . $DBI::errstr . "\n";

    $self->dbh($dbh);

    my $recordset = AMF::Perl::Sql::MysqlRecordSet->new($dbh);
    $self->recordset($recordset);

    return $self;
}


sub recordset
{
    my ($self, $val) = @_;
    $self->{recordset} = $val if $val;
    return $self->{recordset};
}

sub dbh
{
    my ($self, $val) = @_;
    $self->{dbh} = $val if $val;
    return $self->{dbh};
}

1;

doc/examples/petmarket/petmarket/api/stringresourcesservice.pm  view on Meta::CPAN

        $strings{"ITEM_LBL_str"}="Item";
        $strings{"PRICE_LBL_str"}="Price";
        $strings{"QTY_AVAILABLE_LBL_str"}="Qty Available";
        $strings{"QTY_LBL_str"}="Qty";
        $strings{"PRODUCT_LBL_str"}="Product";
        $strings{"ITEMS_IN_CART_LBL_str"}="Items:";
        $strings{"CART_SUBTOTAL_LBL_str"}="Subtotal:";
        $strings{"ADVERT_COPY_DEFAULT_str"}="Keep your pets healthy and happy with\n Pet Market brand pet foods.";
        $strings{"ADVERT_COPY_CONTEXT_str"}="Keep your pet healthy! Try our special formula of pet foods, available in assorted sizes and flavors.";
        $strings{"OK_BTN_LBL_str"}="OK";
        $strings{"EXCEEDS_AVAILABLE_MB_MSG_str"}="The quantity you entered exceeds the number we currently have available. The quantity will be automatically reset to the maximum available at this time.";
        $strings{"EXCEEDS_AVAILABLE_MB_TTL_str"}="Quantity Available Exceeded";
        $strings{"REQUIRED_FIELD_INDICATOR_str"}="*";
        $strings{"ERROR_FIELD_INDICATOR_str"}="<";
        $strings{"NUMBER_SYMBOL_str"}="-";
        $strings{"DATE_SEPARATOR_str"}="/";
        $strings{"ADDRESS_LBL_str"}="Address:";
        $strings{"CITY_LBL_str"}="City:";
        $strings{"STATE_LBL_str"}="State:";
        $strings{"ZIP_LBL_str"}="Zip / Postal Code:";
        $strings{"EMAIL_LBL_str"}="E-mail:";

doc/examples/petmarket/petmarket/api/userservice.pm  view on Meta::CPAN

    my ($self, $email, $password) = @_;
    my $ary_ref = $self->dbh->selectall_arrayref("SELECT count(*) FROM user_details where email='$email' AND password='$password'");

    return $ary_ref->[0]->[0] > 0;
}

sub addUser
{
    my ($self, $email, $password) = @_;
	
    $self->dbh->do("INSERT INTO user_details set email='$email', password='$password'");

    my $result = new AMF::Perl::Util::Object;
    $result->{"useroid"} = $email;
    $result->{"email"} = $email;
    $result->{"password"} = $password;

    return $result;
}


doc/examples/petmarket/petmarket/api/userservice.pm  view on Meta::CPAN

    $result->{useroid} = $email;
    return $result;
}

sub updateUser
{
    my ($self, $userObject) = @_;

    return 0 unless $self->authenticate($userObject->{"email"}, $userObject->{"password"});

    my $setString = "";

    my @setStringArray = map {"$_='".$userObject->{$_}."'"} @userFields;
    $setString = join ",", @setStringArray;

    $self->dbh->do("UPDATE user_details SET $setString");

    return $userObject;
}

1;

doc/examples/sql/DataGlue.as  view on Meta::CPAN

	this.dataProvider = dataProvider;
}
 
// specify a format string for each line of text
_global.DataGlue.bindFormatStrings = function (dataConsumer, dataProvider, labelString, dataString)
{
	var proxy = new DataGlue(dataProvider);
	proxy.labelString = labelString;
	proxy.dataString = dataString;
	proxy.getItemAt = _global.DataGlue.getItemAt_FormatString;
	dataConsumer.setDataProvider(proxy);
}
 
// let a user-supplied function handle formatting of each data record
_global.DataGlue.bindFormatFunction = function (dataConsumer, dataProvider, formatFunction)
{
	var proxy = new DataGlue(dataProvider);
	proxy.formatFunction = formatFunction;
	proxy.getItemAt = _global.DataGlue.getItemAt_FormatFunction;
	dataConsumer.setDataProvider(proxy);
}

_global.DataGlue.prototype.addView = function(viewRef)
{
	return this.dataProvider.addView(viewRef);
}

_global.DataGlue.prototype.getLength = function()
{
	return this.dataProvider.getLength();

doc/examples/sql/README.txt  view on Meta::CPAN


1. Make sure you have access to a mysql database and that the DBI and DBD::Mysql modules are installed.
2. Import the park.sql script into your database.
3. Don't forget to put DataGlue.as in the same directory as the Flash movie.
4. Recompile the Flash movie to point to the location of your park.pl script.


Note that normally AMF::Perl tries to guess whether you are sending a number. 
And if the database used is Mysql, AMF::Perl will retrieve column types
from the statement handle. This is done so that the server could send back
primitive data types in a recordset as numbers or strings avoiding the
guessing (which may be wrong if you do intend to send a number as a string).

doc/examples/sql/park.pl  view on Meta::CPAN

# The code is based on the -PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client
#talking in ActionScript. See the AMF::Perl project site (http://www.simonf.com/amfperl)
#for more information.

use strict;
use AMF::Perl;

my $gateway = AMF::Perl->new;
$gateway->setBaseClassPath("./parkservices/");
$gateway->debugDir("/tmp");
$gateway->service();

doc/examples/sql/parkservices/ParkService.pm  view on Meta::CPAN


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

    my $dbh = DBI->connect("DBI:mysql:host=$dbhost:db=$dbname","$dbuser","$dbpass",{ PrintError=>1, RaiseError=>1 })
        or die "Unable to connect: " . $DBI::errstr . "\n";

	my $recordset = AMF::Perl::Sql::MysqlRecordSet->new($dbh);
	$self->recordset($recordset);

    return $self;
}


sub recordset
{
    my ($self, $val) = @_;
    $self->{recordset} = $val if $val;
    return $self->{recordset};
}

sub dbh
{
    my ($self, $val) = @_;
    $self->{dbh} = $val if $val;
    return $self->{dbh};
}


doc/examples/sql/parkservices/ParkService.pm  view on Meta::CPAN

            "access" => "remote", 
			"returns" => "AMFObject"
        }
    };
    
}

sub getParkTypes()
{
    my ($self) = @_;
    return $self->recordset->query("SELECT Distinct(parktype) FROM tblparks WHERE parktype is not NULL order by parktype");
}

sub getParksList
{
    my ($self, $parkType) = @_;
	my $select = "SELECT parkName,city,state,parktype FROM tblparks ";
	$select .=  " WHERE parktype='$parkType' " if $parkType;
	$select .= "ORDER BY parkname";
    return  $self->recordset->query($select);
}

sub getParkDetails
{
    my ($self, $thisParkName) = @_;
    return  $self->recordset->query("SELECT * FROM tblparks WHERE parkname='".$thisParkName."'");
}


1;

doc/index.html  view on Meta::CPAN

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="content-type"
 content="text/html; charset=ISO-8859-1">
  <title>AMF::Perl - Flash Remoting in Perl and Python</title>
  <style>
body {  
	scrollbar-3d-light-color:		#000000; 
	scrollbar-arrow-color:			#000066; 
	scrollbar-base-color:			#003366; 
	scrollbar-dark-shadow-color:	#FFFFFF; 
	scrollbar-face-color:			#003366; 
	scrollbar-highlight-color:		#FFFFFF; 
	scrollbar-shadow-color:			#000000;

doc/index.html  view on Meta::CPAN

      <br><br>
      <a href="code.html">Usage instructions and code samples.</a><br>
      <br>
      <h2>What is this?</h2>
      <h3> Short version<br>
      </h3>
      <a href="http://www.macromedia.com/software/flashremoting/">Flash
Remoting</a> is a way for Flash movies running in a web browser to
request structured data from the web server. The following data types
are supported - strings, numbers, dates, arrays, dictionaries/hashes,
objects, recordsets. Flash clients talk with the server using the AMF
protocol, which is proprietary to Macromedia. However, it's not that
hard to decode. <br>
      <br>
Using AMF::Perl, it is possible to send arbitrary
data between client and server using very few lines of code. There is no
need to pack complicated data structures into CGI form parameteres or
XML strings. The coding time can be spent on better things - data
preparation and graphical presentation, not data delivery.<br>
      <br>
      <h3>Long version</h3>

doc/index.html  view on Meta::CPAN

 href="code.html">This is what the code looks like.</a><br>
To build/export .swf files with Flash Remoting, you need to install
Flash Remoting MX Components for free at:<br>
http://www.macromedia.com/software/flashremoting/downloads/components/
<br>
This will install the scripts "NetServices.as" and "NetDebug.as" that are
used in the ActionScript.
      </p>
      <p>We think that it is very important for the Open Source
community to make this technology available in Perl and (why not?) in
Python as well. We set out to decode the protocol, but soon discovered
that <a href="http://amfphp.sourceforge.net/">PHP folks</a> beat us by a
month, so we simply rewrote their code in Perl.</p>
<p>We would like to hear the community feedback - the amount of time we
will put into this project will be proportional to the need for it.<br>
      <br>
<p>Please respond if you are interested either in using AMF::Perl or in
contributing to it.<br>
      <br>
      <br>
      </td>

doc/index.html  view on Meta::CPAN

      <a href="mailto:arva@cshl.edu"><span style="font-style: italic;">Adrian
Arva</span></a><br style="font-style: italic;">
      <br>
<p>The initial code is based on the <a
 href="http://amfphp.sourceforge.net/">AMF-PHP project.</a><br>
<p>There also exists a <a href=http://www.flashorb.com>shareware (but not open-source) Java and .NET
implementation</a> of server-side Flash Remoting.
      <br><br>
<p>Created on Feb 24, 2003.<br>
      <p><a href="updates.html">Update history</a> (last updated July 06, 2004)
<p>	Mailing list on SourceForge is set up. Please <a href=http://lists.sourceforge.net/lists/listinfo/flaph-general>go here to subscribe</a>.
</td>
    </tr>
    <tr>
      <td style="vertical-align: top;"><br>
      </td>
    </tr>
  </tbody>
</table>
</div>
<br>

doc/updates.html  view on Meta::CPAN

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="content-type"
 content="text/html; charset=ISO-8859-1">
  <title>AMF::Perl - Flash Remoting in Perl</title>
  <style>
body {  
	scrollbar-3d-light-color:		#000000; 
	scrollbar-arrow-color:			#000066; 
	scrollbar-base-color:			#003366; 
	scrollbar-dark-shadow-color:	#FFFFFF; 
	scrollbar-face-color:			#003366; 
	scrollbar-highlight-color:		#FFFFFF; 
	scrollbar-shadow-color:			#000000;

doc/updates.html  view on Meta::CPAN

		<br><br>Jul 06, 2004. Version 0.13 uploaded. Small bug fixes, exception handling.

		<br><br>Apr 29, 2004. Version 0.12 uploaded. Changed "use Apache2" to "require Apache2".

		<br><br>Apr 24, 2004. Flash::FLAP renamed to AMF::Perl. Version 0.11 uploaded (0.10 was an interim release). Hopefully complete mod_perl 1 and 2 handling. Mysql column type determination.

		<br><br>Mar 13, 2004. Version 0.09 uploaded. Fixed a couple of "uninitialized" warnings, accepted patches for POD documentation, smarter detection of numbers and dates in Serializer and text encoding.

		<br><br>Aug 3, 2003. Version 0.08 uploaded. Petstore example implemented!!! Also, rewrote Flash::FLAP::new() to accept both Flash::FLAP->new and $flap->new.

		<br><br>Jul 26, 2003. Version 0.07 uploaded. Fixed a bug that would wrongly detect end-of-file in the input data on Windows and replaced the "our" keyword that is not backwards-compatible. Created pseudo_query() in Util::Object that encapsulates th...

		<br><br>Jun 22, 2003. Version 0.06 uploaded. Added an example that talks to a database on the server side. This is implemented via Flash::FLAP::Sql::MysqlRecordSet.pm. Got rid of a couple of "uninitialized" warnings.

		<br><br>Apr 29, 2003. Version 0.05 uploaded. It supports Windows and mod_perl 1.

        <br><br>Apr 14, 2003 - FLAP renamed to Flash::FLAP. Version 0.03 uploaded. Added ser
vice discovery - now you can register a directory and put Perl packages in it. Every
 package will be considered a service. Macromedia Service Browser support added.

<br>

lib/AMF/Perl.pm  view on Meta::CPAN


Or, if you have many services to register, create a package corresponding to each service
and put them into a separate directory. Then register this directory name. 

In the example below directory "services" may contain Foo.pm, Bar.pm etc.
Therefore, services Foo and Bar are available. However, these packages must have a function
called methodTable returning the names and descriptions of all possible methods to invoke.
See the documentation and examples for details.

	my $gateway = AMF::Perl->new;
	$gateway->setBaseClassPath('./services');
	$gateway->service();



=head1 ABSTRACT

    Macromedia Flash Remoting server-side support.

=head1 DESCRIPTION

lib/AMF/Perl.pm  view on Meta::CPAN

    my $amfin = $deserializer->getObject();
    
    # we can add much functionality with the headers here, like turn on server debugging, etc.
    my $headercount = $amfin->numHeader();
    
    for (my $i=0; $i<$headercount; $i++)
    {
        my $header = $amfin->getHeaderAt($i);
        if ($header->{'key'} eq "DescribeService")
        {
            $self->{exec}->setHeaderFilter("DescribeService");
        }
        # other headers like net debug config
        # and Credentials
    }

    
    # get the number of body elements
    my $bodycount = $amfin->numBody();
    
    # create Object for storing the output
    my $amfout = new AMF::Perl::Util::Object();
    
    # loop over all of the body elements
    for (my $i=0; $i<$bodycount; $i++)
    {
        my $body = $amfin->getBodyAt($i);
        # set the packagePath of the executive to be our method's uri
        #Simon - unused for now
        $self->{exec}->setTarget( $body->{"target"} );
        #/Simon
        # execute the method and pass it the arguments
        
       	my ($results, $returnType);

        # try
        eval
        {
           $results =  $self->{exec}->doMethodCall( $body->{"value"} );
           # get the return type

lib/AMF/Perl.pm  view on Meta::CPAN

}

sub debugDir
{
    my ($self, $dir) = @_;
    $self->{debugDir} = $dir if $dir;
    return $self->{debugDir};
}


sub setBaseClassPath
{
    my ($self, $path) = @_; 
    if (-d $path)
    {
        $self->{exec}->setBaseClassPath($path);
    }
    else
    {
        print STDERR "Directory $path does not exist and could not be registered.\n";
        die;
    }
}

sub registerService
{

lib/AMF/Perl.pm  view on Meta::CPAN



sub amf_throw
{
    my ($description) = @_;

    AMFException->throw( error => constructException($description) );
}


sub setSafeExecution
{
    my ($self, $safe) = @_;
    print STDERR "There is no need to call setSafeExecution anymore!\n";
}

sub encoding
{
	my $self = shift;
	$self->{encoding} = shift if @_;
	return $self->{encoding};
}

#    usefulldebugging method 

lib/AMF/Perl/App/Executive.pm  view on Meta::CPAN

=head2 Sun Mar 23 13:27:00 EST 2003

=over 4

=item Synching with AMF-PHP:

=item Replaced packagepath, packagename, packageConstruct with classpath, classname, classConstruct.

=item Added _instanceName, _origClassPath and _headerFilter.

=item Added subs setHeaderFilter(), setInstanceName()

=item Renamed setClassPath to setTarget and removed extra junk from that function.

=item Eliminated _getPackage() and _getMethod().

=item Removed safeExecution().

=back

=head2 Tue Mar 11 21:59:27 EST 2003

=item Passing @$a instead of $a to user functions. $a always is an array.

lib/AMF/Perl/App/Executive.pm  view on Meta::CPAN

sub new
{
    my ($proto)=@_;
    my $self={};
    bless $self, $proto;
    return $self;
    # nothing really to do here yet?
}


# setter for the _headerFilter
sub setHeaderFilter 
{
    my ($self, $header) = @_;
    $self->{_headerFilter} = $header;
}

# Set the base classpath. This is the path from which will be search for the packagees and functions
# $basecp should end with a "/";
sub setBaseClassPath
{
    my ($self, $basecp) = @_; 
    $self->{_basecp} = $basecp; 
}

sub setInstanceName
{  
    my ($self, $name) = @_; 
    $self->{_instanceName} = $name;
}

# you pass directory.script.method to this and it will build
# the classpath, classname and methodname values
sub setTarget
{
    my ($self, $target)=@_;
    $self->{target} = $target;
    # grab the position of the last . char
    my $lpos = strrpos($target, ".");
    # there were none
    unless ($lpos) 
    {
        print STDERR "Service name $target does not contain a dot.\n";
        # throw an error because there has to be atleast 1

lib/AMF/Perl/App/Executive.pm  view on Meta::CPAN

            print STDERR  "Access error for " . $self->{_headerFilter} . ".\n";
            return;
            }
        }
        
        # check to see if an explicit return type was defined
        if (exists($methodrecord{'returns'}))
        {
            $self->{_returnType} = $methodrecord{'returns'};
        }
        # set the default return type of "unknown"
        else
        {
            $self->{_returnType} = "unknown";
        }
        # set to see if the access was set and the method as remote permissions.
        if ( (exists($methodrecord{'access'})) && (lc ($methodrecord{'access'}) eq "remote"))
        {
            # finally check to see if the method existed
            if ($self->{_classConstruct}->can($method))
            {
                # execute the method and return it's results to the gateway
                return $self->{_classConstruct}->$method(@$a);
            }
            else
            {

lib/AMF/Perl/App/Executive.pm  view on Meta::CPAN


    	if ($serviceobject->can("methodTable") && exists ($serviceobject->methodTable->{$method}))
    	{
			# create a shortcut to the methodTable
        	my %methodrecord = %{$serviceobject->methodTable->{$method}};
        	# check to see if an explicit return type was defined
        	if (exists($methodrecord{'returns'}))
        	{
            	$self->{_returnType} = $methodrecord{'returns'};
        	}
        	# set the default return type of "unknown"
        	else
        	{
            	$self->{_returnType} = "unknown";
        	}
		}
        return $serviceobject->$method(@$a);
    }    
}

sub strrpos

lib/AMF/Perl/IO/Serializer.pm  view on Meta::CPAN


=head2 Sun May 23 12:35:19 EDT 2004

=item Changed deduceType() to return the value too, as it may be changed inside, and to 
handle empty string ('') as a string.

=head2 Wed Apr 14 11:06:28 EDT 2004

=item Made basic data type determination work for both scalars and scalarrefs.

=item Now we check if we are sending a recordset and setting column types accordingly.

=head2 Sat Mar 13 16:25:00 EST 2004

=item Patch from Tilghman Lesher that detects numbers and dates in strings
and sets return type accordingly.

=item Patch from Kostas Chatzikokolakis handling encoding and sending null value.

=head2 Sun May 11 16:43:05 EDT 2003

=item Changed writeData to set type to "NULL" when the incoming data is undef. Previously
it became a String, just like other scalars.

=item Changed PHP's writeRecordset to a generic writeAMFObject. Verified Recordset support.

=head2 Sun Mar  9 18:20:16 EST 2003

=item Function writeObject should return the same as writeHash. This assumes that all meaningful data
are stored as hash keys.

=cut


use strict;

lib/AMF/Perl/IO/Serializer.pm  view on Meta::CPAN


sub writeXML
{
    my ($self, $d)=@_;
    $self->{out}->writeByte(15);
    #$self->{out}->writeLongUTF(utf8_encode($d));
	from_to($d, $self->{encoding}, "utf8") if $self->{encoding};
    $self->{out}->writeLongUTF($d);
}

# must be used PHPRemoting with the service to set the return type to date
# still needs a more in depth look at the timezone
sub writeDate
{
    my ($self, $d)=@_;
    # write date code
    $self->{out}->writeByte(11);
    # write date (milliseconds from 1970)
    $self->{out}->writeDouble($d);
    # write timezone
    # ?? this is wierd -- put what you like and it pumps it back into flash at the current GMT ?? 

lib/AMF/Perl/IO/Serializer.pm  view on Meta::CPAN

    # grab the total number of elements
    my $len = scalar(@$d);

    # write the numeric array code
    $self->{out}->writeByte(10);
    # write the count of items in the array
    $self->{out}->writeLong($len);
    # write all of the array elements
    for(my $i=0 ; $i < $len ; $i++)
    {
		#If this is a basic data type in a recordset, consider the column type.
		if (!(ref $d->[$i]) && $self->{__writingRecordset__})
		{
			my $type = $self->{__columnTypes__}->[$i];
			$self->dispatchBySqlType($d->[$i], $type);
		}
		else
		{
        	$self->writeData($d->[$i]);
		}
    }
}

lib/AMF/Perl/IO/Serializer.pm  view on Meta::CPAN

sub writeObject
{
    my ($self, $d)=@_;
    # loop over each element
    while ( my ($key, $data) = each %$d)
    {	
        # write the name of the object
        $self->{out}->writeUTF($key);
		if ($self->{__columnTypes__} && $key eq "initialData")
		{
			$self->{__writingRecordset__} = 1;
		}
        # write the value of the object
        $self->writeData($data);
		$self->{__writingRecordset__} = 0;
    }
    # write the end object flag 0x00, 0x00, 0x09
    $self->{out}->writeInt(0);
    $self->{out}->writeByte(9);
}

# write an AMF object
# The difference with regular object is that the code is different 
# and the class name is explicitly sent. Good for RecordSets.
sub writeAMFObject

lib/AMF/Perl/IO/Serializer.pm  view on Meta::CPAN

    # XML
    elsif (lc($type) eq "xml")
    {
        $self->writeXML($d);
    }
    # Dates
    elsif (lc($type) eq "date")
    {
        $self->writeDate($d);
    }
    # mysql recordset resource
    elsif (lc($type) eq "amfobject") # resource type
    {
        # write the record set to the output stream
        $self->writeAMFObject($d); # writes recordset formatted for Flash
    }		
    else
    {
        print STDERR "Unsupported Datatype $type in AMF::Perl::IO::Serializer";
        die;
    }
    
    }

sub deduceType

lib/AMF/Perl/Util/Object.pm  view on Meta::CPAN

    Translated from PHP Remoting v. 0.5b from the -PHP project.        

=head1 DESCRIPTION    

    Package used for building and retreiving  header and body information

=head1 CHANGES

=head2 Wed Apr 14 11:06:28 EDT 2004

=item Saving column types in the __columnTypes__ field for the recordset object.

Sun Jul 27 16:52:12 EDT 2003

=item Added the pseudo_query() method to create a recordset object wanted by Flash.

=cut

use strict;

# constructor
sub new
{
    my ($proto)=@_;
    my $self = {};

lib/AMF/Perl/Util/Object.pm  view on Meta::CPAN

    my $result = new AMF::Perl::Util::Object;
    # create the serverInfo array
    $result->{"serverInfo"} = {};

# create an initialData array
    my (@initialData, @columnNames);
    $result->{serverInfo}->{initialData} = $data;
    $result->{serverInfo}->{columnNames} = $columnNames;
    $result->{serverInfo}->{totalCount}= scalar @$data;

    # create the id field --> i think this is used for pageable recordsets
    $result->{"serverInfo"}->{"id"} = "AMF::Perl";
    $result->{"serverInfo"}->{"cursor"} = 1; # maybe the current record ????
    $result->{"serverInfo"}->{"serviceName"} = "doStuff"; # in CF this is PageAbleResult not here
    # versioning
    $result->{"serverInfo"}->{"version"} = 1;

    $result->{_explicitType}='RecordSet';

    $result->{__columnTypes__}=$columnTypes;



( run in 0.928 second using v1.01-cache-2.11-cpan-49f99fa48dc )