def test_batch(): client = rockets.Client(server_url) request_1 = rockets.Request("double", [2]) request_2 = rockets.Request("double", [4]) notification = rockets.Notification("foobar") responses = client.batch([request_1, request_2, notification]) assert_equal(len(responses), 2) results = list(map(lambda x: x.result, responses)) assert_equal(results, [4, 8])
async def hello(websocket, path): while True: message = await websocket.recv() try: json_message = json.loads(message) method = json_message["method"] if method == "NotifyMe": notification = rockets.Notification("Hello") await websocket.send(str(notification.json)) except Exception: greeting = "Hello {0}!".format(message) await websocket.send(greeting) if message == "Rockets": break
async def hello(websocket, path): await send_message notification = rockets.Notification('set-test-object', {'string': 'changed'}) await websocket.send(str(notification.json)) await close_server