Daisuke Murase

NAME

Catalyst::Controller::FlashRemoting - Catalyst controller for Flash Remoting

SYNOPSIS

    package MyApp::Controller::Gateway;
    use strict;
    use warnings;
    use base qw/Catalyst::Controller::FlashRemoting/;
    
    sub gateway :Path :AMFGateway { }
    
    sub echo :AMFMethod {
        my ($self, $c, $args) = @_;
    
        return $args;
    }
    
    sub sum :AMFMethod('sum') {
        my ($self, $c, $args) = @_;
    
        return $args->[0] + $args->[1];
    }

DESCRIPTION

Catalyst::Controller::FlashRemoting is a Catalyst controller that provide easy interface for Flash Remoting.

Flash Remoting is RPC subsystem and that use AMF (Action Message Format) as message body format.

USAGE

At first, you need api gateway (endpoint) controller. Add AMFGateway attribute to catalyst action for that.

    sub gateway :Local :AMFGateway { }

If you write above code in Root controller, then 'http://localhost:3000/gateway' is AMF Gateway url.

To use this gateway, write actionscript3 like this:

    var nc:NecConnection = new NetConnection();
    nc.connect("http://localhost:3000/gateway");

Second, you need create some methods.

    sub echo :AMFMethod {
        my ($self, $c, $args) = @_;
        return $args;
    }
    
    sub sum :AMFMethod('sum') {
        my ($self, $c, $args) = @_;
    
        return $args->[0] + $args->[1];
    }

'echo' is echoback method that just return same object to request, and 'sum' method sum up two arguments and return the result.

To call these methods, write actionscript3 like this:

    nc.call("echo", responder, "foo bar");  // result "foo bar"
    nc.call("sum", responder, 1, 2);        // result 3

responder is actionscript3's Responder object. see flex/flash docs for detail.

ACTION ATTRIBUTES

AMFGateway

This attribute makes the controller to act as AMF Gateway. the controller automatically parse AMF request, dispatch amf method (see AMFMethod attribute below), and serialize response and return.

AMFMethod($method_name)

This attribute makes the controller to act as AMF Method. This is called from AMFGateway, and don't have to be catalyst controller.

$method_name argument is optional. When no $method_name passed, the actual method name is used as amf method name.

METHODS

new

_parse_AMFGateway_attr

_parse_AMFMethod_attr

SEE ALSO

Data::AMF, Data::AMF::Packet.

AUTHOR

Daisuke Murase <typester@cpan.org>

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.