Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added unicode test to WebSocket example
  • Loading branch information
kraih committed Jan 11, 2013
1 parent 07e197e commit 3249875
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/websocket.pl
@@ -1,10 +1,12 @@
use FindBin;
use lib "$FindBin::Bin/../lib";
use Mojolicious::Lite;
use Mojo::JSON 'j';

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

# Minimal WebSocket application for browser testing
Expand All @@ -28,7 +30,7 @@
alert(data);
}
function wsopen(event) {
ws.send("WebSocket support works!");
ws.send(JSON.stringify({test: "♥ WebSocket support works! ♥"}));
}
ws.onmessage = wsmessage;
ws.onopen = wsopen;
Expand Down

0 comments on commit 3249875

Please sign in to comment.