Prevent host countdown from going negative

This commit is contained in:
Andrew Guibert 2018-10-16 08:37:14 -05:00
parent 186e2e8b59
commit 30c210d1f5
2 changed files with 13 additions and 7 deletions

View File

@ -455,8 +455,12 @@ export class GameComponent implements OnInit, OnDestroy {
this.waitingTimer = timer(0, 1000);
this.waitingSub = this.waitingTimer.subscribe((t) => {
if (this.waitCard) {
this.verifyOpen();
this.waitCard.bodyString = `${seconds - t}`;
// If we have gotten down to -2, a connection was probably interrupted
if (-1 > (seconds - t)) {
this.waitingSub.unsubscribe();
this.connectionInterrupted();
}
}
});
@ -485,15 +489,18 @@ export class GameComponent implements OnInit, OnDestroy {
}
verifyOpen() {
console.log('@AGG verify open');
if (!this.gameService.isOpen()) {
console.log('GameService socket not open');
this.ngZone.run(() => {
this.router.navigate(['/login']);
});
this.connectionInterrupted();
}
}
connectionInterrupted() {
alert('Connection to game-service interrrupted. Re-directing to login page.');
this.ngZone.run(() => {
this.router.navigate(['/login']);
});
}
addBorder(x, y, w, h) {
let shape: Shape = new Shape();
shape.shadow = new Shadow(Obstacle.COLOR, 0, 0, 20);

View File

@ -67,7 +67,6 @@ public class PartyQueue {
}
public int queuePosition() {
int i = 0;
int position = 1;
for (QueuedClient c : PartyQueue.this.waitingPlayers) {
if (this.equals(c))