AMF-Connection

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

the client sends a request to the server to be processed and the server returns a response to the client
containing the processing outcome. Data is sent back and forth in AMF binary format (AMFChannel). Other access patterns
such as pub/sub and channels transport are out of scope of this inital release.

[1] http://en.wikipedia.org/wiki/Action_Message_Format

See public github repo http://github.com/areggiori/AMF-Connection

INSTALLATION

To install this module type the following:

   perl Makefile.PL
   make
   make test
   make install

DEPENDENCIES

This module requires these other modules and libraries:

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

                   'startHit' => int($startHit),
                   'searchString' => $searchString,
                   'hitsPerPage' => ($hitsPerPage) ? int($hitsPerPage) : 20,
                   'sortId' => $sortId,
       }, 'com.mycompany.application.flex.data.SearchQueryFx');

my $response = $client->call( "MySearchSevice.searchAdvanced", [ $searchAMFObject ] );

#....

For other Java to ActionScript type mappings possibilities see http://livedocs.adobe.com/blazeds/1/javadoc/flex/messaging/io/amf/ActionMessageOutput.html#writeObject(java.lang.Object)

For PHP gateways at the moment there is not a known/documented way to map client to server objects.

Future versions of AMF::Connection may add a proper configurable factory for application specific ActionScript/Flex object mappings.

=head1 METHODS

=head2 new ($endpoint)

Create new AMF::Connection object. An endpoint can be specified as the only parameter. Or set in a second moment with the setEndpoint() method.

=head2 call ($operation, $arguments)

Call the remote service method with given parameters/arguments on the set endpoint and return an AMF::Connection::MessageBody response. Or an array of responses if requsted (wantarray call scope). The $arguments is generally an array reference, but t...

=head2 callBatch (@batch)

Call the remote service once in batch. Each element of @batch must be an hash like { "operation" => $operation, "arguments" => $arguments }, where $operation and $arguments are as specified in C<call>. The commands are called and responses returned i...

=head2 setEndpoint ($endpoint)

Set the AMF service endpoint.

=head2 getEndpoint ()

lib/AMF/Connection/InputStream.pm  view on Meta::CPAN

	my @long = unpack("N",$block);

        return $long[0];
	};

# deparse out the next avail AMF entity
# TODO - make sure ref counts are reset/preserved between calls in the scope of the same InputStream - study Storable::AMF API
sub readAMFData {
	my ($class) = @_;

	my $type = $class->readByte();

	# Storable::AMF will take care of deparsing the right AMF format
	$class->{'cursor'}--;

	local $@ = undef;

        my ($obj, $len);
	my $encoding=0;
	if($type == 0x11) {
		$encoding=3;
		$class->{'cursor'}++;
		if ($storable_with_options  == 0
		    || not defined $class->{'options'})
		  {
        	    ($obj, $len) = Storable::AMF3::deparse_amf( substr($class->{'stream'},$class->{'cursor'}));
		  }
  		else
		  {
        	    ($obj, $len) = Storable::AMF3::deparse_amf( substr($class->{'stream'},$class->{'cursor'}), $class->{'options'});

lib/AMF/Connection/Message.pm  view on Meta::CPAN

	$stream->writeInt(scalar(@{$class->{'headers'}}));
	foreach my $header (@{$class->{'headers'}}) {
		my $name =$header->getName();
		$stream->writeInt(length($name));
		$stream->writeBuffer($name);

		$stream->writeByte($header->isRequired());

		$stream->writeLong(-1);

		# TODO - make sure Storable::AMF does not store string "true" as boolean - or make sure value is right typed
		$stream->writeAMFData( $class->getEncoding(), $header->getValue() );
		};

	$stream->writeInt(scalar(@{$class->{'bodies'}}));
	foreach my $body (@{$class->{'bodies'}}) {
		my $target = $body->getTarget();
		$stream->writeInt(length($target));
		$stream->writeBuffer($target);

		my $response = $body->getResponse();



( run in 1.314 second using v1.01-cache-2.11-cpan-df04353d9ac )