Add websocket event stream for sim updates.

As a proof of concept this only covers the flight positions.
This commit is contained in:
Dan Albert
2022-02-16 01:28:10 -08:00
parent 350f08be2f
commit 21f7912458
14 changed files with 150 additions and 15 deletions

View File

@@ -17,6 +17,7 @@ from .waypointjs import WaypointJs
class FlightJs(QObject):
idChanged = Signal()
positionChanged = Signal()
flightPlanChanged = Signal()
blueChanged = Signal()
@@ -50,6 +51,10 @@ class FlightJs(QObject):
self.ato_model = ato_model
self._waypoints = self.make_waypoints()
@Property(str, notify=idChanged)
def id(self) -> str:
return str(self.flight.id)
def update_waypoints(self) -> None:
for waypoint in self._waypoints:
waypoint.timingChanged.emit()

View File

@@ -125,12 +125,6 @@ class MapModel(QObject):
self.cleared.emit()
def on_sim_update(self, events: GameUpdateEvents) -> None:
# TODO: Only update flights with changes.
# We have the signal of which flights have updates, but no fast lookup for
# Flight -> FlightJs since Flight isn't hashable. Faster to update every flight
# than do do the O(n^2) filtered update.
for flight in self._flights.values():
flight.positionChanged.emit()
for combat in events.new_combats:
self.on_add_combat(combat)
for combat in events.updated_combats: