From 5bccd5d5fdafac4f7c6b8b80bc2d409d42ab0815 Mon Sep 17 00:00:00 2001 From: keroxp Date: Tue, 18 Feb 2020 07:14:47 +0900 Subject: [PATCH 1/3] [ws] Added browser chat example --- std/examples/README.md | 10 ++++- std/examples/chat/index.html | 74 ++++++++++++++++++++++++++++++++++++ std/examples/chat/server.ts | 60 +++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 std/examples/chat/index.html create mode 100644 std/examples/chat/server.ts diff --git a/std/examples/README.md b/std/examples/README.md index 351c4a6b4c7c4c..b4d276cdb26d84 100644 --- a/std/examples/README.md +++ b/std/examples/README.md @@ -10,7 +10,7 @@ bookmark to a program.) ### A TCP echo server ```shell -deno https://deno.land/std/examples/echo_server.ts --allow-net +deno --allow-net https://deno.land/std/examples/echo_server.ts ``` Or @@ -51,3 +51,11 @@ deno install --allow-net --allow-env gist https://deno.land/std/examples/gist.ts gist --title "Example gist 1" script.ts gist --t "Example gist 2" script2.ts ``` + +### chat - WebSocket chat server and browser client + +```shell +deno --allow-net --allow-read https://deno.land/std/examples/chat/server.ts +``` + +Open http://localhost:8080 on the browser. diff --git a/std/examples/chat/index.html b/std/examples/chat/index.html new file mode 100644 index 00000000000000..c3463196c9b64b --- /dev/null +++ b/std/examples/chat/index.html @@ -0,0 +1,74 @@ + + + +
+ + + + +
+
+