websocket client
This commit is contained in:
parent
20c30d0b05
commit
f0a50632ee
1 changed files with 29 additions and 0 deletions
29
utils/wsclient.py
Executable file
29
utils/wsclient.py
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/python3 -u
|
||||
import argparse
|
||||
|
||||
import websocket
|
||||
|
||||
|
||||
def get_parser():
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument(
|
||||
"--trace", action="store_true", default=False, help="Extra debugging"
|
||||
)
|
||||
p.add_argument("url")
|
||||
return p
|
||||
|
||||
|
||||
def on_message(wsapp, msg):
|
||||
print(msg)
|
||||
|
||||
|
||||
def main():
|
||||
args = get_parser().parse_args()
|
||||
|
||||
websocket.enableTrace(args.trace)
|
||||
wsapp = websocket.WebSocketApp(args.url, on_message=on_message)
|
||||
wsapp.run_forever()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in a new issue