NAME
Mercury::Controller::PushPull - Push/pull message pattern controller
VERSION
version 0.016
SYNOPSIS
# myapp.pl
use Mojolicious::Lite;
plugin 'Mercury';
websocket( '/push/*topic' )
->to( controller => 'PushPull', action => 'push' );
websocket( '/pull/*topic' )
->to( controller => 'PushPull', action => 'pull' );
DESCRIPTION
This controller enables a push/pull pattern on a pair of endpoints (push and pull.
For more information on the push/pull pattern, see Mercury::Pattern::PushPull.
METHODS
push
$app->routes->websocket( '/push/*topic' )
->to( controller => 'PushPull', action => 'push' );
Controller action to connect a websocket to a push endpoint. A push client sends messages through the socket. The message will be sent to one of the connected pull clients in a round-robin fashion.
This endpoint requires a topic
in the stash.
pull
$app->routes->websocket( '/pull/*topic' )
->to( controller => 'PushPull', action => 'pull' );
Controller action to connect a websocket to a pull endpoint. A pull client will recieve messages from push clients in a round-robin fashion. One message from a pusher will be received by exactly one puller.
This endpoint requires a topic
in the stash.
post
Post a new message to the given topic without subscribing or establishing a WebSocket connection. This allows new messages to be easily pushed by any HTTP client.
SEE ALSO
AUTHOR
Doug Bell <preaction@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2018 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.