fixed writing empty board

This commit is contained in:
leca 2023-08-02 11:07:24 +03:00
parent 8d0d75125c
commit 576a88765f
1 changed files with 16 additions and 6 deletions

View File

@ -1,4 +1,4 @@
const WebSocket = require('ws'); const WebSocket = require('wss');
const express = require('express'); const express = require('express');
const http = express(); const http = express();
const path = require('path'); const path = require('path');
@ -25,6 +25,7 @@ var board = new Array(boardWidth * boardHeight * 4);
if (!fs.existsSync(saveFile)) { if (!fs.existsSync(saveFile)) {
console.log("No save file found, creating blank board."); console.log("No save file found, creating blank board.");
board.fill(255); board.fill(255);
let image = new Jimp(boardWidth, boardHeight, save);
} else { } else {
console.log("Save file found, loading") console.log("Save file found, loading")
let image = Jimp.read(`./${saveFile}`, (err, image) => { let image = Jimp.read(`./${saveFile}`, (err, image) => {
@ -43,13 +44,22 @@ if (!fs.existsSync(saveFile)) {
} }
const ws = new WebSocket.Server({
port: appPort,
host: "0.0.0.0",
const server = new WebSocket.Server({ handleProtocols: true,
port: appPort server: httpsServer
// AddressInfo.family = 4;
// server: true
}); });
// var ws = require('ws').Server;
// const server = new ws({})
console.log(server)
// const server = new WebSocket.Server({ http });
let clients = []; let clients = [];
let lastPixelTimestamp = []; let lastPixelTimestamp = [];
const evaulatePixelNumber = (x, y) => { const evaulatePixelNumber = (x, y) => {