Skip to content

Commit

Permalink
minor fixes to work with the latest node.js
Browse files Browse the repository at this point in the history
  • Loading branch information
inolen committed Dec 7, 2016
1 parent 237acdf commit 5660b0b
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions bin/master.js
Expand Up @@ -298,18 +298,20 @@ function loadConfig(configPath) {
return;
}

buffer = (new Uint8Array(buffer)).buffer; // node Buffer to ArrayBuffer

// check to see if this is emscripten's port identifier message
var wasfirst = first;
first = false;
if (wasfirst &&
buffer.byteLength === 10 &&
buffer[0] === 255 && buffer[1] === 255 && buffer[2] === 255 && buffer[3] === 255 &&
buffer[4] === 'p'.charCodeAt(0) && buffer[5] === 'o'.charCodeAt(0) && buffer[6] === 'r'.charCodeAt(0) && buffer[7] === 't'.charCodeAt(0)) {
conn.port = ((buffer[8] << 8) | buffer[9]);
return;
}
// node Buffer to ArrayBuffer
var view = Uint8Array.from(buffer);
var buffer = view.buffer;

// check to see if this is emscripten's port identifier message
var wasfirst = first;
first = false;
if (wasfirst &&
view.byteLength === 10 &&
view[0] === 255 && view[1] === 255 && view[2] === 255 && view[3] === 255 &&
view[4] === 'p'.charCodeAt(0) && view[5] === 'o'.charCodeAt(0) && view[6] === 'r'.charCodeAt(0) && view[7] === 't'.charCodeAt(0)) {
conn.port = ((view[8] << 8) | view[9]);
return;
}

var msg = stripOOB(buffer);
if (!msg) {
Expand Down Expand Up @@ -339,9 +341,10 @@ function loadConfig(configPath) {
});
});

server.listen(config.port, function() {
console.log('master server is listening on port ' + server.address().port);
});
// listen only on 0.0.0.0 to force ipv4
server.listen(config.port, '0.0.0.0', function() {
console.log('master server is listening on port ' + server.address().port);
});

setInterval(pruneServers, pruneInterval);
})();

0 comments on commit 5660b0b

Please sign in to comment.