Skip to content

Commit

Permalink
examples: websocket: Improve with filter and simpler url
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric committed Sep 2, 2022
1 parent 61963f0 commit 7dc4ef3
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions examples/websocket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,27 @@ async def dispatch():
ARGS = argparse.ArgumentParser(
description="websocket console client for wssrv.py example."
)
ARGS.add_argument(
"--filter",
action="store",
dest="filter",
default=".*",
help="Regex filter or message name used on websocket: ATTITUDE,HEARTBEAT,RAW_IMU",
)
ARGS.add_argument(
"--url",
action="store",
dest="url",
default="http://0.0.0.0:8088/ws/mavlink?filter=.*",
help="Websocket address, follow the format: http://0.0.0.0:8088/ws/mavlink?filter={regex}",
default="http://blueos.local:6040",
help="Websocket address, follow the format: http://0.0.0.0:8088",
)

if __name__ == "__main__":
args = ARGS.parse_args()

loop = asyncio.get_event_loop()
asyncio.Task(start_client(args.url))
loop.run_forever()
loop = asyncio.new_event_loop()
loop.run_until_complete(
start_client(
args.url + "/ws/mavlink" + f"?filter={args.filter}"
)
)

0 comments on commit 7dc4ef3

Please sign in to comment.