dcs_liberation/game/server/dependencies.py
Dan Albert 350f08be2f Add FastAPI interface between the game and map.
A possible explanation for the infrequent CTDs we've been seeing since
adding fast forward is that QWebChannel doesn't keep a reference to the
python objects that it passes to js, so if the object is GC'd before the
front end is done with it, it crashes.

We don't really like QWebChannel anyway, so this begins replacing that
with FastAPI.
2022-02-15 18:14:34 -08:00

16 lines
315 B
Python

from game import Game
class GameContext:
_game: Game | None
@classmethod
def set(cls, game: Game | None) -> None:
cls._game = game
@classmethod
def get(cls) -> Game:
if cls._game is None:
raise RuntimeError("GameContext has no Game set")
return cls._game