#!/usr/bin/env python3 import asyncio import json import sys async def main() -> int: try: import websockets except ImportError: print("NO_WEBSOCKETS") return 2 url = "wss://game.xworld.ren/ws?pid=m2_probe" print("connecting", url) try: async with websockets.connect(url, open_timeout=10, close_timeout=5) as ws: print("OPEN ok") try: msg = await asyncio.wait_for(ws.recv(), timeout=3) print("recv", type(msg).__name__, repr(msg)[:800]) except asyncio.TimeoutError: print("recv_timeout (no hello)") hello = {"op": "hello", "proto": 1, "app": "1.0.0", "pid": "m2_probe"} await ws.send(json.dumps(hello, ensure_ascii=False)) print("sent", hello) try: msg = await asyncio.wait_for(ws.recv(), timeout=5) print("after_hello", type(msg).__name__, repr(msg)[:800]) except asyncio.TimeoutError: print("after_hello_timeout") return 0 except Exception as e: print("ERR", type(e).__name__, e) return 1 if __name__ == "__main__": raise SystemExit(asyncio.run(main()))