fixed timer and removed connect feature
This commit is contained in:
parent
465b78627e
commit
49de12b51a
|
@ -1,5 +1,6 @@
|
||||||
var serverAddress = document.getElementById("server-address").value;
|
var serverAddress = document.getElementById("server-address").textContent;
|
||||||
var serverPort = document.getElementById("server-port").value
|
var serverPort = document.getElementById("server-port").textContent;
|
||||||
|
|
||||||
var socket
|
var socket
|
||||||
|
|
||||||
var canvas = document.getElementById("board");
|
var canvas = document.getElementById("board");
|
||||||
|
@ -73,8 +74,8 @@ function connect() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
serverAddress = document.getElementById("server-address").value;
|
var serverAddress = document.getElementById("server-address").textContent;
|
||||||
serverPort = document.getElementById("server-port").value
|
var serverPort = document.getElementById("server-port").textContent;
|
||||||
|
|
||||||
console.log()
|
console.log()
|
||||||
|
|
||||||
|
|
12
src/index.js
12
src/index.js
|
@ -132,18 +132,14 @@ server.on('connection', (client) => {
|
||||||
let unixTime = Math.floor(new Date().getTime() / 1000);
|
let unixTime = Math.floor(new Date().getTime() / 1000);
|
||||||
if (lastPixelTimestamp[client.id] == undefined || unixTime - lastPixelTimestamp[client.id] > timeBetweenPixels - 1) {
|
if (lastPixelTimestamp[client.id] == undefined || unixTime - lastPixelTimestamp[client.id] > timeBetweenPixels - 1) {
|
||||||
lastPixelTimestamp[client.id] = unixTime;
|
lastPixelTimestamp[client.id] = unixTime;
|
||||||
for (let i = 0; i < clients.length; i++) {
|
clients.forEach((c) => {
|
||||||
response.pixelOwner = i == client.id ? true : false;
|
response.pixelOwner = c.id == client.id? true : false;
|
||||||
clients[i].send(Buffer.from(JSON.stringify(response)));
|
c.send(Buffer.from(JSON.stringify(response)));
|
||||||
board[pixelNumber + 0] = contentJson.r;
|
board[pixelNumber + 0] = contentJson.r;
|
||||||
board[pixelNumber + 1] = contentJson.g;
|
board[pixelNumber + 1] = contentJson.g;
|
||||||
board[pixelNumber + 2] = contentJson.b;
|
board[pixelNumber + 2] = contentJson.b;
|
||||||
board[pixelNumber + 3] = 255;
|
board[pixelNumber + 3] = 255;
|
||||||
}
|
})
|
||||||
// clients.forEach(c => c.send(Buffer.from(JSON.stringify(response))));
|
|
||||||
// client.send("{\"code\":2}")
|
|
||||||
} else {
|
|
||||||
// client.send("{\"code\":3}")
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case undefined:
|
case undefined:
|
||||||
|
|
|
@ -5,12 +5,15 @@ html(lang='en')
|
||||||
meta(charset="UTF-8")
|
meta(charset="UTF-8")
|
||||||
body(style="background-color: grey;")
|
body(style="background-color: grey;")
|
||||||
p
|
p
|
||||||
| Server to connect:
|
| Server:
|
||||||
- var server
|
- var server
|
||||||
input(type="text" id="server-address" value=server)
|
b(id="server-address") #{server}
|
||||||
|
| :
|
||||||
- var port
|
- var port
|
||||||
input(type="number" id="server-port" value=port)
|
b(id="server-port") #{port}
|
||||||
input(type="button" id="server-button" value="connect" onclick="connect()")
|
//- input(type="text" id="server-address" value=server)
|
||||||
|
//- input(type="number" id="server-port" value=port)
|
||||||
|
//- input(type="button" id="server-button" value="connect" onclick="connect()")
|
||||||
p
|
p
|
||||||
input(type="color" id="color")
|
input(type="color" id="color")
|
||||||
br
|
br
|
||||||
|
|
Loading…
Reference in New Issue