NAME

RPC::ExtDirect::Event - The way to pass data to client side

SYNOPSIS

use RPC::ExtDirect;
use RPC::ExtDirect::Event;

 sub foo : ExtDirect( pollHandler ) {
    my ($class) = @_;

    # Do something good, collect results to $good_data
    my $good_data = { ... };

    # Do something bad, collect results to $bad_data
    my $bad_data = [ ... ];

    # Return the data
    return (
                RPC::ExtDirect::Event->new('good', $good_data),
                RPC::ExtDirect::Event->new('bad',  $bad_data ),
           );
}

DESCRIPTION

This module implements Event object that is used to return events or some kind of data from EventProvider handlers to the client side.

Data can be anything that is serializable to JSON. No checks are made and it is assumed that client side can understand format of the data sent with Events.

Note that by default JSON will blow up if you try to feed it a blessed object as data payload, and for very good reason: it is not obvious how to serialize a self-contained object. Each case requires specific handling which is not feasible in a framework like this; therefore no effort was made to support serialization of blessed objects. If you know that your object is nothing more than a hash containing simple scalar values and/or structures of scalar values, create a copy like this:

my $hashref = {};
@$hashref{ keys %$object } = values %$object;

But in reality, it almost always is not as simple as this.

METHODS

new($name, $data)

Creates a new Event object with event $name and some $data.

run()

Not intended to be called directly, provided for duck type compatibility with Exceptions and Request.

result()

Returns Event hashref in format supported by Ext.Direct client stack. Not intended to be called directly.

BUGS AND LIMITATIONS

There are no known bugs in this module.

AUTHOR

Alexander Tokarev <tokarev@cpan.org>

COPYRIGHT AND LICENSE

Copyright (c) 2011 Alexander Tokarev.

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