2023-01-31 12:34:13 +00:00
|
|
|
class Player {
|
2023-01-29 16:47:37 +00:00
|
|
|
constructor(id, name) {
|
|
|
|
this.name = name;
|
|
|
|
this.timeout = null;
|
|
|
|
this.id = id;
|
|
|
|
this.ready = false;
|
2023-02-02 11:27:52 +00:00
|
|
|
this.isPlaying = false;
|
2023-01-29 16:47:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resetTimeout() {
|
|
|
|
if (this.timeout !== null) {
|
2023-01-31 12:34:13 +00:00
|
|
|
window.clearTimeout(this.timeout);
|
2023-01-29 16:47:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.timeout = window.setTimeout(() => {
|
|
|
|
delete players[this.id];
|
|
|
|
updatePlayerDom();
|
|
|
|
}, TIMEOUT);
|
|
|
|
}
|
|
|
|
}
|