refactor: load

This commit is contained in:
cha0s 2024-05-27 12:52:30 -05:00
parent 9643055fb8
commit 3dc7cf8a5b
3 changed files with 5 additions and 0 deletions

View File

@ -53,6 +53,9 @@ export default class Server {
this.entities.splice(this.entities.indexOf(entity), 1); this.entities.splice(this.entities.indexOf(entity), 1);
} }
async load() {
}
start() { start() {
return setInterval(() => { return setInterval(() => {
const elapsed = (Date.now() - this.last) / 1000; const elapsed = (Date.now() - this.last) / 1000;

View File

@ -12,6 +12,7 @@ const server = new class SocketServer extends Server {
send(ws, data) { ws.send(JSON.stringify(data)); } send(ws, data) { ws.send(JSON.stringify(data)); }
} }
await server.load();
server.start(); server.start();
wss.on('connection', function connection(ws) { wss.on('connection', function connection(ws) {

View File

@ -4,6 +4,7 @@ const server = new class WorkerServer extends Server {
send(connection, data) { postMessage(data); } send(connection, data) { postMessage(data); }
} }
await server.load();
server.start(); server.start();
server.connectPlayer(undefined); server.connectPlayer(undefined);