http://www.perlmonks.org?node_id=1152459


in reply to Re^5: real-time output from Mojolicious WebSockets?
in thread real-time output from Mojolicious WebSockets?

actually i have same question,
There is long-time operation on server and I want update its progress on client-side.
In several points on server-side code I call $web_socket->send(...) and process it on client-side ws.onmessage = function (event) {...};
Server-side logic as below:
some_computation1();
$web_socket->send('computation1 end');
...
some_computation15();
$web_socket->send('computation15 end');
...
some_computation100();
$web_socket->send('computation100 end. All ok!');
Client-side as below
ws = new WebSocket(url);
ws.onmessage = function (event) {
$('#log_view').append('

' + event.data + '

');
};
ws.onopen = function (event) {
...
};
ws.onclose = function (event) {
...
};
Everything work fine, but not in realtime: all messages has received by client at one big bulk list and only after whole server-side script has finished.
in fact, i need every message show up after one step finished.
appreciate if any friends can help me.