Merge from old Gitea

This commit is contained in:
Jon
2026-04-12 16:06:44 +01:00
commit aaefb2bb35
18 changed files with 492 additions and 0 deletions

33
examples/game_events.py Normal file
View File

@@ -0,0 +1,33 @@
#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())