Now that we can receive game messages from several games at once, make sure the Game module only handles the ones for the current game

This commit is contained in:
Tissevert 2020-01-28 18:24:34 +01:00
parent 81216e3f01
commit c5e5a7c958

View file

@ -80,12 +80,14 @@ function previously(states) {
function initMessageHandlers() { function initMessageHandlers() {
window.addEventListener('focus', catchUp); window.addEventListener('focus', catchUp);
Messaging.addEventListener(["Game"], function(o) { Messaging.addEventListener(["Game"], function(o) {
if(o.state.public.coordinates.gameID == globalState.game.public.coordinates.gameID) {
delay(handleGameMessage(o.state)); delay(handleGameMessage(o.state));
if(document.hasFocus() && getQueue().length == 1) { if(document.hasFocus() && getQueue().length == 1) {
catchUp(); catchUp();
} else { } else {
StatusHandler.set("♪"); StatusHandler.set("♪");
} }
}
}); });
} }