mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
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.
This commit is contained in:
15
game/server/dependencies.py
Normal file
15
game/server/dependencies.py
Normal file
@@ -0,0 +1,15 @@
|
||||
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
|
||||
Reference in New Issue
Block a user