Skip to content

Commit

Permalink
docs: create GeneralsIO client example
Browse files Browse the repository at this point in the history
The with block is important, thats how the websocket connection is
automatically handled. It can be ommited by instiantiating the
GeneralsIOClient directly, but it will require manual call for
disconnect. For details, see:
https://python-socketio.readthedocs.io/en/latest/client.html#creating-a-client-instance
  • Loading branch information
revolko committed Oct 19, 2024
1 parent b73618d commit 4bcc394
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/client_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from generals.agents.random_agent import RandomAgent
from generals.remote import GeneralsIOClient


if __name__ == "__main__":
agent = RandomAgent()
with GeneralsIOClient(agent, "user_id9l") as client:
# register call will fail when given username is already registered
client.register_agent("[Bot]MyEpicUsername")
client.join_private_game("queueID")
client.wait_for_game()

0 comments on commit 4bcc394

Please sign in to comment.