Skip to content

Commit

Permalink
How not to use exports
Browse files Browse the repository at this point in the history
  • Loading branch information
codergautam committed Nov 17, 2024
1 parent e598a32 commit e6721db
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
5 changes: 3 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ var app = express();
import cors from 'cors';
import cityGen from './serverUtils/cityGen.js';
import User from './models/User.js';
import { currentDate } from './ws/ws.js';

function currentDate() {
return new Date().toLocaleString("en-US", { timeZone: "America/Chicago" });
}
app.use(cors());
app.use(bodyParser.json({limit: '5mb'}));
app.use(bodyParser.urlencoded({limit: '5mb', extended: true, parameterLimit:50000}));
Expand Down
8 changes: 7 additions & 1 deletion ws/classes/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,17 @@ export default class Game {
usedHint: false,
maxDist: this.maxDist
})
} else {
console.error('No location found for round', this.curRound, this.locations);
}

}
} else {
// subtract the difference of the score from the lower scored player

const loc = this.locations[this.curRound - 1];
if(loc) {

const p1= this.players[Object.keys(this.players)[0]];
const p2 = this.players[Object.keys(this.players)[1]];
if(!p1 || !p2) {
Expand Down Expand Up @@ -175,7 +179,9 @@ export default class Game {
}

}

} else {
console.error('No location found for round', this.curRound, this.locations);
}
}
}

Expand Down
10 changes: 9 additions & 1 deletion ws/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let maintenanceMode = false;
let dbEnabled = true;

//get current date &time in cst
export function currentDate() {
function currentDate() {
return new Date().toLocaleString("en-US", { timeZone: "America/Chicago" });
}

Expand Down Expand Up @@ -1266,6 +1266,14 @@ app.ws('/wg', {
}, 10000);
}


setInterval(() => {
// log player count, game count, memory usage
const memUsage = process.memoryUsage().heapUsed;
const gameCnt = games.size;
const playerCnt = players.size;
console.log('Players:', playerCnt, 'Games:', gameCnt, 'Memory:', memUsage);
}, 5000)
// // Check for pong messages and disconnect inactive clients
// setInterval(() => {
// const currentTime = Date.now();
Expand Down

0 comments on commit e6721db

Please sign in to comment.