From 8b646e8657309e57bd4e907f911529e33e3a05fb Mon Sep 17 00:00:00 2001 From: Yusuke Sakurai Date: Sun, 23 Feb 2020 08:51:04 +0900 Subject: Added browser chat example (#4022) --- std/examples/README.md | 10 +++++- std/examples/chat/index.html | 76 ++++++++++++++++++++++++++++++++++++++++ std/examples/chat/server.ts | 65 ++++++++++++++++++++++++++++++++++ std/examples/chat/server_test.ts | 46 ++++++++++++++++++++++++ 4 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 std/examples/chat/index.html create mode 100644 std/examples/chat/server.ts create mode 100644 std/examples/chat/server_test.ts (limited to 'std/examples') diff --git a/std/examples/README.md b/std/examples/README.md index 4f12f2a02..ea85da542 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 000000000..b84a9f1dd --- /dev/null +++ b/std/examples/chat/index.html @@ -0,0 +1,76 @@ + + + ws chat example + + +
+ + + + +
+
+