You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
759 B

2 years ago
import {Room} from "../room"
import {Client} from "../client"
export class ServerGame {
room: Room;
settings: Settings.Global;
game: any;
constructor(room: Room, settings: Settings.Global) {
this.settings = settings;
this.room = room;
this.room.clients.forEach(c => this.addClient(c))
}
addClient(client: Client): void {
this.setEvents(client)
}
removeClient(client: Client): void {
this.removeEvents(client)
}
gameAction(action: string, ...args: any[]): void {
}
setEvents(client: Client): void {
let socket = client.socket;
socket.on('game-action', (action, ...args) => this.gameAction(action, ...args))
}
removeEvents(client: Client): void {
let socket = client.socket;
socket.removeAllListeners('game-action')
}
}