![]() |
![]()
| ![]() |
![]()
NAMEJifty::Plugin::PubSub::Connection - Connection to browser DESCRIPTIONThis class represents a bidirectional channel between the server and the web browser. You may wish to subclass this class as "YourApp::PubSub" to override the "connect", "receive", or "disconnect" methods. METHODSconnectCalled when a connection is established from the browser. By default, does nothing. subscribe TOPIC [, TOPIC, ...]Subscribes the browser to receive messages on the given topics. send TYPE DATASends an arbitrary message to the browser. It is not published to the rest of the message bus. receive DATACalled when a message is received from the web browser; returns true if the message was processed, false otherwise. If you override this method, be sure you respect this class' return value: sub receive { my $self = shift; my $msg = shift; return 1 if $self->SUPER::receive( $msg ); # ... } disconnectCalled when the connection to the browser is lost when the browser switches to a new page. This is not immediate, but occurs after a 15-second timeout. webReturns the constructed Jifty::Web object which is seen as "Jifty-"web> whenever in the context of this connection's "connect", "receive", "disconnect", or when page regions are rendered to be sent over this channel. This ensures that "Jifty-"web->current_user> is set whenever it is relevant. apiA new Jifty::API object is instantiated for each Jifty::Plugin::PubSub::Connection object. You may wish to limit it to limit which actions can be performed by the web browser. listenerThe AnyMQ::Queue object which listens to events for the client. client_idReturns a unique identifier associated with this connection. action_message DATACreates, validates, and runs an action if it was received by the client; called by "receive". region_event EVENTCalled when one or more regions on the page needs to be rendered and pushed to the client, as triggered by an event. The rendered regions will be passed EVENT as an "event" variable. Currently, rendered regions cannot alter the client's subscription set.
|