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