Fix race condition

This commit is contained in:
Florian Mounier
2015-10-06 10:17:14 +02:00
parent 811620557a
commit cf5051d414
4 changed files with 11 additions and 11 deletions

File diff suppressed because one or more lines are too long

View File

@@ -13,6 +13,7 @@
document.addEventListener('DOMContentLoaded', function() {
var ctl, lastData, queue, send, t_queue, term, treat, ws, wsUrl;
term = null;
send = function(data) {
return ws.send('S' + data);
};
@@ -35,6 +36,9 @@
ws = new WebSocket(wsUrl);
ws.addEventListener('open', function() {
console.log("WebSocket open", arguments);
term = new Terminal(document.body, send, ctl);
term.ws = ws;
window.butterfly = term;
ws.send('R' + term.cols + ',' + term.rows);
return openTs = (new Date()).getTime();
});
@@ -78,14 +82,11 @@
return open('', '_self').close();
}
});
term = new Terminal(document.body, send, ctl);
addEventListener('beforeunload', function() {
if (!quit) {
return 'This will exit the terminal session';
}
});
term.ws = ws;
window.butterfly = term;
window.bench = function(n) {
var rnd;
if (n == null) {

File diff suppressed because one or more lines are too long

View File

@@ -22,7 +22,7 @@ openTs = (new Date()).getTime()
$ = document.querySelectorAll.bind(document)
document.addEventListener 'DOMContentLoaded', ->
term = null
send = (data) ->
ws.send 'S' + data
@@ -43,6 +43,9 @@ document.addEventListener 'DOMContentLoaded', ->
ws.addEventListener 'open', ->
console.log "WebSocket open", arguments
term = new Terminal document.body, send, ctl
term.ws = ws
window.butterfly = term
ws.send 'R' + term.cols + ',' + term.rows
openTs = (new Date()).getTime()
@@ -84,14 +87,10 @@ document.addEventListener 'DOMContentLoaded', ->
if (new Date()).getTime() - openTs > 60 * 1000
open('','_self').close()
term = new Terminal document.body, send, ctl
addEventListener 'beforeunload', ->
if not quit
'This will exit the terminal session'
term.ws = ws
window.butterfly = term
window.bench = (n=100000000) ->
rnd = ''