Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use Mojolicious::Lite;
- use Mojo::IOLoop;
- my $testpayload = '0123456789' x 165536;
- get '/' => sub {
- my $self = shift();
- $self->render;
- } => 'index';
- websocket '/websocket' => sub {
- my $self = shift();
- warn("Got connection\n");
- $self->send({text => $testpayload});
- };
- app->secret('BoxOfAssortedCreams');
- app->start;
- __DATA__
- @@ layouts/default.html.ep
- <!doctype html><html>
- <head>
- <title><%= title %></title>
- <script type="text/javascript">
- function wsobj() {
- var _self = this;
- this.start = function() {
- var ws = new WebSocket('ws://' + document.location.host.toString() + '/websocket');
- ws.onclose = function(e) {
- clearTimeout(_self.refresh);
- setTimeout(_self.start, 2000);
- }
- ws.onopen = function () {
- console.log('WebSocket Connection Opened');
- };
- ws.onmessage = function(evt) {
- alert("Received " + evt.data.length + " bytes");
- };
- }
- _self.start();
- }
- new wsobj();
- </script>
- </head>
- <body><%= content %></body>
- </html>
- @@ index.html.ep
- % layout 'default';
- % title 'Large Payload Websocket Test';
- <h1>Large Payload Websocket Test</h1>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement