The Comet has Crashed!
Run perl shell.pl daemon -l 'http://*:7000'.Type in command and press "Run"
Runws = new WebSocket( 'ws://localhost:7000/' );
ws.onopen = function () {
var cmd = $( '#command' ).val();
ws.send( cmd );
};
ws.onmessage = function ( msg ) {
$( '#output' ).append( msg.data );
// Scroll to the bottom of the output panel
$( '#output' ).scrollTop( $( '#output' ).prop('scrollHeight') );
};
websocket '/' => sub {
my ( $c ) = @_;
$c->on( message => sub { ... } );
};
my ( $c, $msg ) = @_; my $pid = open my $fh, '-|', $msg;
my $stream = Mojo::IOLoop::Stream->new( $fh );
$stream->on( read => sub {
my ( $stream, $bytes ) = @_;
$c->app->log->debug( "Sending output: $bytes" );
$c->send( $bytes );
} );
$stream->on( close => sub {
kill KILL => $pid;
close $fh;
} );
my $sid = Mojo::IOLoop->stream( $stream );
$c->on( finish => sub {
Mojo::IOLoop->remove( $sid );
} );