diff --git a/rpi/controllers/GameController.py b/rpi/controllers/GameController.py index f648cfdb..84f68dc4 100644 --- a/rpi/controllers/GameController.py +++ b/rpi/controllers/GameController.py @@ -42,6 +42,9 @@ class GameController: print(ex) return jsonify({"status": "error", "message": f"An error occurred : {ex}"}), 500 + def stop_game(self): + self._game_service.stop() + def make_move(self): try: auth_token = request.headers.get("Authorization") diff --git a/rpi/main.py b/rpi/main.py index 1de9cbbe..1b3e65bc 100644 --- a/rpi/main.py +++ b/rpi/main.py @@ -27,6 +27,7 @@ api_password = os.environ.get("API_PASSWORD") app = Flask(__name__) forwarder_service = None +game_controller = GameController(app) if __name__ == "__main__": @@ -52,7 +53,6 @@ if __name__ == "__main__": ) forwarder_service = ForwarderService(local_broker, api_broker) - game_controller = GameController(app) forwarder_service.register_forwarder(client_id, "rfid", "/system/sensor/rfid", f"/customer/telemetry/rfid", 2) forwarder_service.register_forwarder(client_id, "light", "/system/sensor/light", f"/customer/telemetry/light", 1) @@ -74,12 +74,12 @@ if __name__ == "__main__": except KeyboardInterrupt: print("Keyboard interrupt. Stopping app...") - #game_service.stop() + game_controller.stop_game() forwarder_service.stop_all() exit() except Exception as e: print(e) - #game_service.stop() + game_controller.stop_game() forwarder_service.stop_all() exit() \ No newline at end of file