12 lines
311 B
Python
12 lines
311 B
Python
|
|
import asyncio
|
||
|
|
import websockets
|
||
|
|
import json
|
||
|
|
import sys
|
||
|
|
|
||
|
|
async def send_msg(msg):
|
||
|
|
async with websockets.connect('ws://localhost:8765') as ws:
|
||
|
|
await ws.send(json.dumps({'type':'chat_message','content':msg,'username':'antigravity'}))
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
asyncio.run(send_msg(sys.argv[1]))
|