Mojolicious::Plugin::PNGCast - in-process server to display a screencast
Use this web application to display the screencast of a (headless) web browser or other arbitrary PNG data sent to it via websocket.
The synopsis shows how to use this plugin to display a Chrome screencast using WWW::Mechanize::Chrome.
use Mojolicious::Lite; use Mojo::Server::Daemon; use WWW::Mechanize::Chrome; plugin 'PNGCast'; my $daemon_url = 'http://localhost:3000'; my $ws_monitor = Mojo::Server::Daemon->new(app => app()); $ws_monitor->listen([$daemon_url]); $ws_monitor->start; my $mech = WWW::Mechanize::Chrome->new( headless => 1 ); $mech->setScreenFrameCallback( sub { app->send_frame( $_[1]->{data} )} ); print "Watch progress at $daemon_url\n"; sleep 5; $mech->get('https://example.com');
app->send_frame
app->send_frame( $png_data );
Sends a frame to all connected clients. If a fresh client connects, it will receive the last frame handed to send_frame.
send_frame
$plugin->notify_clients
$plugin->notify_clients( $PNGframe )
Notify all connected clients that they should display the new frame.
This plugin makes the following endpoints available
/ - the index page
/
This is an HTML page that opens a websocket to the webserver and listens for PNG images coming in over that websocket
/ws - the websocket
/ws
This is a websocket
/stop - stop the application
/stop
This stops the complete Mojolicious application
The public repository of this module is https://github.com/Corion/Mojolicious-Plugin-PNGCast.
The public support forum of this module is https://perlmonks.org/.
Please report bugs in this module via the RT CPAN bug queue at https://rt.cpan.org/Public/Dist/Display.html?Name=Mojolicious-Plugin-PNGCast or via mail to Mojolicious-Plugin-PNGCast-Bugs@rt.cpan.org.
Max Maischein corion@cpan.org
corion@cpan.org
Copyright 2010-2018 by Max Maischein corion@cpan.org.
This module is released under the same terms as Perl itself.
To install Mojolicious::Plugin::PNGCast, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::PNGCast
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::PNGCast
For more information on module installation, please visit the detailed CPAN module installation guide.