fixed timer and removed connect feature

This commit is contained in:
leca 2024-04-08 00:56:50 +03:00
parent 465b78627e
commit 49de12b51a
3 changed files with 17 additions and 17 deletions

View File

@ -1,5 +1,6 @@
var serverAddress = document.getElementById("server-address").value;
var serverPort = document.getElementById("server-port").value
var serverAddress = document.getElementById("server-address").textContent;
var serverPort = document.getElementById("server-port").textContent;
var socket
var canvas = document.getElementById("board");
@ -73,8 +74,8 @@ function connect() {
});
}
serverAddress = document.getElementById("server-address").value;
serverPort = document.getElementById("server-port").value
var serverAddress = document.getElementById("server-address").textContent;
var serverPort = document.getElementById("server-port").textContent;
console.log()

View File

@ -132,18 +132,14 @@ server.on('connection', (client) => {
let unixTime = Math.floor(new Date().getTime() / 1000);
if (lastPixelTimestamp[client.id] == undefined || unixTime - lastPixelTimestamp[client.id] > timeBetweenPixels - 1) {
lastPixelTimestamp[client.id] = unixTime;
for (let i = 0; i < clients.length; i++) {
response.pixelOwner = i == client.id ? true : false;
clients[i].send(Buffer.from(JSON.stringify(response)));
clients.forEach((c) => {
response.pixelOwner = c.id == client.id? true : false;
c.send(Buffer.from(JSON.stringify(response)));
board[pixelNumber + 0] = contentJson.r;
board[pixelNumber + 1] = contentJson.g;
board[pixelNumber + 2] = contentJson.b;
board[pixelNumber + 3] = 255;
}
// clients.forEach(c => c.send(Buffer.from(JSON.stringify(response))));
// client.send("{\"code\":2}")
} else {
// client.send("{\"code\":3}")
})
}
break;
case undefined:

View File

@ -5,12 +5,15 @@ html(lang='en')
meta(charset="UTF-8")
body(style="background-color: grey;")
p
| Server to connect:
- var server
input(type="text" id="server-address" value=server)
| Server:
- var server
b(id="server-address") #{server}
| :
- var port
input(type="number" id="server-port" value=port)
input(type="button" id="server-button" value="connect" onclick="connect()")
b(id="server-port") #{port}
//- 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
input(type="color" id="color")
br