Files
esa-python-sdk/examples/game_events.py
2026-04-12 16:06:44 +01:00

33 lines
890 B
Python

#TODO: This needs IMP to be implemented as a websocket message not just a control panel message
import asyncio
import time
from esasdk import Machine
async def main():
# Connect to a machine
machine = Machine("ws://localhost:5424")
await machine.connect()
# start a game
gameCode = "MAES"
countdown = 5
duration = 15
await machine.game_start(gameCode, 0, countdown, duration)
print(f"running {gameCode}")
# wait for impact event - TODO: use 3491 socket or improve websocket?
await machine._await_message("IMP")
print("Impact!")
# program in game events like seconds remaining and hits/misses.
# wait for game stopped signal to know the game has stopped.
#await machine.game_stop()
await machine.game_stop_signal()
# Close connection
await machine.close()
if __name__ == "__main__":
asyncio.run(main())