From 796fc9bc3e8e4da7d53fb4617511ce4e2be22485 Mon Sep 17 00:00:00 2001 From: Andrey Trebler Date: Mon, 4 May 2020 18:27:06 +0200 Subject: BREAKING: make WebSocket directly implement AsyncIterable (#5044) (#5045) --- std/examples/chat/server.ts | 2 +- std/examples/chat/server_test.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'std/examples') diff --git a/std/examples/chat/server.ts b/std/examples/chat/server.ts index a86ed737a..cb1be530e 100644 --- a/std/examples/chat/server.ts +++ b/std/examples/chat/server.ts @@ -18,7 +18,7 @@ async function wsHandler(ws: WebSocket): Promise { const id = ++clientId; clients.set(id, ws); dispatch(`Connected: [${id}]`); - for await (const msg of ws.receive()) { + for await (const msg of ws) { console.log(`msg:${id}`, msg); if (typeof msg === "string") { dispatch(`[${id}]: ${msg}`); diff --git a/std/examples/chat/server_test.ts b/std/examples/chat/server_test.ts index d1c1a8afa..92eb50f92 100644 --- a/std/examples/chat/server_test.ts +++ b/std/examples/chat/server_test.ts @@ -59,7 +59,8 @@ test({ let ws: WebSocket | undefined; try { ws = await connectWebSocket("http://127.0.0.1:8080/ws"); - const it = ws.receive(); + const it = ws[Symbol.asyncIterator](); + assertEquals((await it.next()).value, "Connected: [1]"); ws.send("Hello"); assertEquals((await it.next()).value, "[1]: Hello"); -- cgit v1.2.3