document.addEventListener('htmx:wsAfterMessage', function (e) {
  try {
    const message = JSON.parse(e.detail.message);
    if (message.type === 'redirect_to_game') {
      window.location.href = '/?gameId=' + message.gameId;
    }
  } catch (error) {
    // some messages are plain divs and some are json. This usually means it was a div one
  }
});
