Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
RPC::ExtDirect::Event(User Contributed Perl DocumentatRPC::ExtDirect::Event(3)

       RPC::ExtDirect::Event - Asynchronous server-to-client events

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

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

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

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

	    # Return the data as a list	(not arrayref!)
	    return (
			RPC::ExtDirect::Event->new('good', $good_data),
			   name	=> 'bad',
			   data	=> $bad_data,

       This module implements Event object that	is used	to send	asynchronous
       events from server to client via	periodic polling.

       Data can	be anything that is serializable to JSON. No checks are	made
       and it is assumed that client side can understand the data format used
       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. To	avoid this, set	a global
       Config option json_options to include "allow_blessed" flag:

	   my $config =	RPC::ExtDirect->get_api->config;
	       allow_blessed =>	1,

	   Constructor.	Creates	a new Event object with	event name and some
	   data.  Accepts arguments by position	as "new($name, $data)",	as
	   well	as by name in a	hash or	hashref:

	       my $event1 = RPC::ExtDirect::Event->new(	'foo', 'bar' );
	       my $event2 = RPC::ExtDirect::Event->new({
		   name	=> 'foo',
		   data	=> 'bar',
	       my $event3 = RPC::ExtDirect::Event->new(
		   name	=> 'foo',
		   data	=> 'bar'

	   This	makes it easier	to extend Event	objects	in a Moose(ish)
	   environment,	etc.

	   Instance method. Not	intended to be called directly,	provided for
	   duck	typing compatibility with Exception and	Request	objects.

	   Instance method. Returns an Event hashref in	format required	by
	   Ext.Direct client stack. Not	intended to be called directly.

perl v5.32.0			  2015-01-30	      RPC::ExtDirect::Event(3)


Want to link to this manual page? Use this URL:

home | help