Skip to content

Commit

Permalink
updated example
Browse files Browse the repository at this point in the history
  • Loading branch information
xantus committed Mar 28, 2010
1 parent 56927e7 commit 453ce5f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions script/websocket-example-1
Expand Up @@ -7,22 +7,27 @@
# and web-socket-js - http://github.com/gimite/web-socket-js # and web-socket-js - http://github.com/gimite/web-socket-js


use FindBin; use FindBin;
die "You need to run 'git submodule update --init' to fetch the example requirements\n"
unless -d "$FindBin::Bin/../mojo/lib";

use lib "$FindBin::Bin/../mojo/lib"; use lib "$FindBin::Bin/../mojo/lib";
use strict;
use warnings;


use Mojolicious::Lite; use Mojolicious::Lite;
use Mojo::Server::Daemon;


@ARGV = qw( daemon ) unless @ARGV; @ARGV = qw( daemon ) unless @ARGV;


websocket '/' => sub { websocket '/' => sub {
my $self = shift; my $self = shift;
$self->send_message( 'Congratulations, your Mojo is working!' ); $self->send_message( 'Congratulations, your Mojo is working!' );
$self->receive_message( $self->finished( sub {
sub { # put your disconnected client handling here
my ( $self, $message ) = @_; } );
$self->send_message( 'echo:'.$message ); $self->receive_message(sub {
} my ( $self, $message ) = @_;
); $self->send_message( 'echo:'.$message );
});
}; };


get '/' => 'index'; get '/' => 'index';
Expand Down

0 comments on commit 453ce5f

Please sign in to comment.