RPC::ExtDirect::Event - The way to pass data to client side
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 ), ); }
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.
Creates a new Event object with event $name and some $data.
Not intended to be called directly, provided for duck type compatibility with Exceptions and Request.
Returns Event hashref in format supported by Ext.Direct client stack. Not intended to be called directly.
There are no known bugs in this module.
Alexander Tokarev <tokarev@cpan.org>
Copyright (c) 2011-2012 Alexander Tokarev.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install RPC::ExtDirect, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RPC::ExtDirect
CPAN shell
perl -MCPAN -e shell install RPC::ExtDirect
For more information on module installation, please visit the detailed CPAN module installation guide.