Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
cleaned up WebSocket example a little
  • Loading branch information
kraih committed Jan 14, 2013
1 parent 0cedac1 commit 3c28daa
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions examples/websocket.pl
Expand Up @@ -3,17 +3,19 @@
use Mojolicious::Lite;
use Mojo::JSON 'j';

any '/' => sub {
websocket '/' => sub {
my $self = shift;
$self->on(
text => sub {
my ($self, $message) = @_;
my $hash = j($message);
my ($self, $data) = @_;
my $hash = j($data);
$hash->{test} = "$hash->{test}";
$self->send({text => j($hash)});
}
) if $self->tx->is_websocket;
} => 'websocket';
);
};

get '/' => 'websocket';

# Minimal WebSocket application for browser testing
app->start;
Expand Down

0 comments on commit 3c28daa

Please sign in to comment.