AMF-Perl

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


0.15 Sun Sep 19 13:01:35 EDT 2004
Converted examples (except for Petmarket) to ActionScript 2.0 under Flash MX 2004.
Patches from Kostas Chatzikokolakis about error checking of input data length.
WriteUTF() writes the string length as long for lengths > 65535.
Also, check for (defined $s) and not just ($s) in writeUTF.

0.14 Sun Jul 11 18:59:36 EDT 2004
Really fixed the number 16 issue (forgot to include the change in 0.13).
Added Richard Boulton's change to readDouble() and writeDouble() to take into account endian-ness.
Changed the behavior of amf_throw() to enable die() to work.

0.13 Sun Jun 20 15:52:57 EDT 2004
Started duplicating changes in this file.

AMF::Perl
Made printing output a separate function, requested by Scott Penrose.
Added and exported amf_throw() that invokes _onStatus callback in Actionscript.

AMF::Perl::IO::OutputStream
Added '$s="" unless $s' in writeUTF() to avoid warnings.

AMF::Perl::IO::InputStream
Improved the check in readDouble to append "0" to the string instead of skipping
the value. Otherwise the number 16 did not go through.
Added defined($thisByte) in readInt, otherwise the character "0" (say, in string length of 30)
did not go through.

Examples / Basic 
Added a button that triggers an exception, thrown in DataEcho.pm

Examples / Petmarket
Fixed catalogservice.pm to not break when search string is not found.


0.12 Thu Apr 29 17:20:07 EDT 2004
AMF::Perl - changed "use Apache2" to "require Apache2".

0.11 Sat Apr 24 21:02:55 EDT 2004
Renamed to AMF::Perl

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


Version: 0.09
Date: March 13, 2004.

1. The "cpu" directory contains an example of simple object registration that returns a complex data structure (array of hashes). The Flash movies shows a bar chart of the current server load as reported by uptime.

2. The "datagrid" directory is an example of using an advanced GUI control in a Flash movie.

3. The "basic" directory shows how data is passed from the client to the server and back. This example employs the advanced service registration when you register a directory and all Perl packages in that directory are automatically considered as ser...

It also shows how to throw exceptions via amf_throw.

4. The "sql" directory is the Parkservice example (borrowed from AMFPHP). It
uses SQL queries.

5. The "petmarket" directory is the Perl implementation of the Macromedia
Petmarket.

Simon Ilyushchenko

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

<table cellspacing=10><tr>
<td align=left width=400 valign=top>
<H2>This is an example of <a href=http://www.simonf.com/amfperl/>AMF::Perl</a> in action.</H2>
<br>
<p>
Download Flash 7 player from <a href="http://www.macromedia.com/shockwave/download/alternates/">here</a> if you don't have it. It even works on Linux!
<p>
This shows various data types passed through AMF to the perl backend and sent back.
The most interesting this is not so much what it does, but how it works. The Perl script utilizes the "service discovery" approach - you simply put Perl modules into a certain directory, and they are automatically registered as services.
<br><br>
This example also shows how to throw exceptions, handled by functionName_onStatus in the Flash client (as opposed to functionName_onResult, which is called normally). Simply include in your Perl code
<pre>
use AMF::Perl qw/amf_throw/;
</pre>

and then call <em>amf_throw()</em> with a string or an arbitrary object as a parameter.
<br><br>
If you call <em>die "Error message"</em>, it will be also caught in the same way and sent as an error to Flash.

<br><br>
<a href=basic.pl>This is the server-side Perl script basic.pl.</a>
<a href=basicservices/DataEcho.pm>This is a sample service DataEcho.pm.</a>
</td>
<td width=600>
&nbsp;&nbsp;&nbsp;
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"

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

    DataEcho
        
==head1 DESCRIPTION    

    Service class used in conjusction with basic.pl
    
    All AMF::Perl service classes must define the method table, where the user can supply optional description and return type.

	If you want to return an error message, handled by functionName_onStatus in the Flash client (as opposed to functionName_onResult, which is normal), include

use AMF::Perl qw/amf_throw/;

and then call amf_throw() with a string or an arbitrary object as a parameter.


==head1 CHANGES

Tue Jul  6 22:06:56 EDT 2004
Added exception throwing via amf_throw().

Sun Apr  6 14:24:00 EST 2003
Created after AMF-PHP.

=cut

use AMF::Perl qw/amf_throw/;



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

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

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

#This function will NOT return the value, because the call to amf_throw() will interrupt
#the control flow and cause the _Status function on the client to be called.
sub generateError
{
    my ($self, $data) = @_;
    amf_throw("An error!!!");
    return "No error";
}

1;

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


# This allows declaration	use AMF::Perl ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
%EXPORT_TAGS = ( 'all' => [ qw(
	
) ] );

@EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );

@EXPORT = qw(amf_throw);

$VERSION = '0.15';


=head1 NAME

AMF::Perl - Flash Remoting in Perl
Translated from PHP Remoting v. 0.5b from the -PHP project.

Main gateway class.  This is always the file you call from flash remoting-enabled server scripts.

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

ORIGINAL PHP Remoting CONTRIBUTORS
    Musicman - original design
    Justin - gateway architecture, class structure, datatype io additions
    John Cowen - datatype io additions, class structure
    Klaasjan Tukker - modifications, check routines, and register-framework

==head1 CHANGES

=head2 Sun Jul 11 18:45:40 EDT 2004

=item Chaned eval{} and amf_throw() to enable die() to work as well (instead of amf_throw()).

=head2 Sun Jun 20 13:32:31 EDT 2004

=over 4

=item Made printing output a separate function, requested by Scott Penrose.

=item Wrote exportable amf_throw() for exception handling.

=back

=head2 Thu Apr 29 17:20:07 EDT 2004

=over 4

=item Changed "use Apache2" to "require Apache2" to avoid breaking on non-modperl systems.

=back

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

    $result{"exceptionStack"} = $stack->as_string;
    my @frames = $stack->frames;
    $result{"details"} = $frames[1]->filename();
    $result{"line"} = $frames[1]->line();
    $result{"level"} = "Error";
    $result{"code"} = "1";
    return \%result;
}


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

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

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
    } 
    else
    {
        # the method name is the very last part
        $self->{_methodname} = substr($target, $lpos+1);
    }
    # truncate the method name from the string
    my $trunced = substr($target, 0, $lpos);
    
    $self->{_classname} = $trunced;

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


# were still lacking dates, xml, and strings longer than 65536 chars
sub writeData
{
    my ($self, $d, $type)=@_;
    $type = "unknown" unless $type;

#    **************** TO DO **********************
#    Since we are now allowing the user to determine
#    the datatype we have to validate the user's suggestion
#    vs. the actual data being passed and throw an error
#    if things don't check out.!!!!
#    **********************************************

    # get the type of the data by checking its reference name
    #if it was not explicitly passed
    if ($type eq "unknown")
    {
		if (!defined $d)		# convert undef to null, but not "" or 0
		{
			$type = "NULL";



( run in 0.353 second using v1.01-cache-2.11-cpan-496ff517765 )