mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 15:57:50 +01:00
beginning admin api
This commit is contained in:
@@ -199,12 +199,7 @@ class GameManager {
|
||||
checkAvailability = (code) => {
|
||||
const game = this.activeGameRunner.activeGames[code.toUpperCase()];
|
||||
if (game) {
|
||||
const unassignedPerson = game.people.find((person) => person.assigned === false);
|
||||
if (!unassignedPerson) {
|
||||
return Promise.resolve(new Error(globals.ERROR_MESSAGE.GAME_IS_FULL));
|
||||
} else {
|
||||
return Promise.resolve({ accessCode: code, playerCount: getGameSize(game.deck), timerParams: game.timerParams });
|
||||
}
|
||||
return Promise.resolve({ accessCode: code, playerCount: getGameSize(game.deck), timerParams: game.timerParams });
|
||||
} else {
|
||||
return Promise.resolve(404);
|
||||
}
|
||||
|
||||
27
server/modules/SocketManager.js
Normal file
27
server/modules/SocketManager.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const globals = require('../config/globals.js');
|
||||
|
||||
class SocketManager {
|
||||
constructor (logger, io) {
|
||||
this.logger = logger;
|
||||
this.io = io;
|
||||
}
|
||||
|
||||
broadcast = (message) => {
|
||||
this.io.emit(globals.EVENTS.BROADCAST, message);
|
||||
};
|
||||
}
|
||||
|
||||
class Singleton {
|
||||
constructor (logger, io) {
|
||||
if (!Singleton.instance) {
|
||||
logger.info('CREATING SINGLETON SOCKET MANAGER');
|
||||
Singleton.instance = new SocketManager(logger, io);
|
||||
}
|
||||
}
|
||||
|
||||
getInstance () {
|
||||
return Singleton.instance;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Singleton;
|
||||
Reference in New Issue
Block a user