Merge branches/quickjs to trunk. This is the way.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3621 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -212,11 +212,17 @@ function handleWebSocketRequest(request, response, client) {
|
||||
packet.push((message.length >> 8) & 0xff);
|
||||
packet.push(message.length & 0xff);
|
||||
} else {
|
||||
var high = 0; //(message.length / (1 ** 32)) & 0xffffffff;
|
||||
var low = message.length & 0xffffffff;
|
||||
packet.push((mask ? (1 << 7) : 0) | 127);
|
||||
packet.push((message.length >> 24) & 0xff);
|
||||
packet.push((message.length >> 16) & 0xff);
|
||||
packet.push((message.length >> 8) & 0xff);
|
||||
packet.push(message.length & 0xff);
|
||||
packet.push((high >> 24) & 0xff);
|
||||
packet.push((high >> 16) & 0xff);
|
||||
packet.push((high >> 8) & 0xff);
|
||||
packet.push((high >> 0) & 0xff);
|
||||
packet.push((low >> 24) & 0xff);
|
||||
packet.push((low >> 16) & 0xff);
|
||||
packet.push((low >> 8) & 0xff);
|
||||
packet.push(low & 0xff);
|
||||
}
|
||||
|
||||
var array = new Uint8Array(packet.length + message.length);
|
||||
@ -235,7 +241,7 @@ function handleWebSocketRequest(request, response, client) {
|
||||
newBuffer.set(data, buffer.length);
|
||||
buffer = newBuffer;
|
||||
|
||||
if (buffer.length >= 2) {
|
||||
while (buffer.length >= 2) {
|
||||
var bits0 = buffer[0];
|
||||
var bits1 = buffer[1];
|
||||
if (bits1 & (1 << 7) == 0) {
|
||||
@ -291,6 +297,8 @@ function handleWebSocketRequest(request, response, client) {
|
||||
}
|
||||
frame = new Uint8Array(0);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -444,24 +452,22 @@ function handleConnection(client) {
|
||||
|
||||
var kBacklog = 8;
|
||||
var kHost = "0.0.0.0"
|
||||
var kHttpPort = gGlobalSettings.httpPort || 12345;
|
||||
var kHttpsPort = gGlobalSettings.httpsPort || null;
|
||||
|
||||
var socket = new Socket();
|
||||
socket.bind(kHost, kHttpPort).then(function() {
|
||||
socket.bind(kHost, tildefriends.http_port).then(function() {
|
||||
var listenResult = socket.listen(kBacklog, function() {
|
||||
socket.accept().then(handleConnection).catch(function(error) {
|
||||
logError("[" + new Date() + "] " + error);
|
||||
logError("[" + new Date() + "] accept error " + error);
|
||||
});
|
||||
});
|
||||
}).catch(function(error) {
|
||||
logError("[" + new Date() + "] " + error);
|
||||
logError("[" + new Date() + "] bind error " + error);
|
||||
});
|
||||
|
||||
if (kHttpsPort) {
|
||||
if (tildefriends.https_port) {
|
||||
var tls = {};
|
||||
var secureSocket = new Socket();
|
||||
secureSocket.bind(kHost, kHttpsPort).then(function() {
|
||||
secureSocket.bind(kHost, tildefriends.https_port).then(function() {
|
||||
return secureSocket.listen(kBacklog, function() {
|
||||
return secureSocket.accept().then(function(client) {
|
||||
handleConnection(client);
|
||||
@ -496,7 +502,7 @@ if (kHttpsPort) {
|
||||
});
|
||||
});
|
||||
}).catch(function(error) {
|
||||
logError("[" + new Date() + "] " + error);
|
||||
logError("[" + new Date() + "] bind error " + error);
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user