From cbeb47218e5ff4c7b39e31c00669e18d2bfdb223 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 26 Feb 2024 13:46:53 +0100 Subject: [PATCH] chore: update playground --- examples/h3/index.ts | 5 ++- examples/h3/public/index.html | 74 ++++++++++++++++++----------------- playground/_index.html.ts | 74 ++++++++++++++++++----------------- 3 files changed, 80 insertions(+), 73 deletions(-) diff --git a/examples/h3/index.ts b/examples/h3/index.ts index 069558a..8eafc73 100644 --- a/examples/h3/index.ts +++ b/examples/h3/index.ts @@ -10,12 +10,15 @@ export const websocket = { hooks: defineHooks({ open(peer) { console.log("[ws] open", peer); + peer.send({ user: "system", message: `Welcome ${peer}!` }); }, message(peer, message) { console.log("[ws] message", peer, message); if (message.text().includes("ping")) { - peer.send("pong"); + peer.send({ user: "system", message: "pong" }); + } else { + peer.send({ user: peer.toString(), message: message.toString() }); } }, diff --git a/examples/h3/public/index.html b/examples/h3/public/index.html index 28d534a..158f051 100644 --- a/examples/h3/public/index.html +++ b/examples/h3/public/index.html @@ -110,6 +110,7 @@ ping, clear, connect, + rand: Math.random(), }).mount(); await connect(); @@ -125,14 +126,11 @@

{{ message.user }}

Avatar -
+

- - - - - +

+ +
+
+ + + + +
diff --git a/playground/_index.html.ts b/playground/_index.html.ts index e211adc..e9a8147 100644 --- a/playground/_index.html.ts +++ b/playground/_index.html.ts @@ -111,6 +111,7 @@ export default /* html */ ` ping, clear, connect, + rand: Math.random(), }).mount(); await connect(); @@ -126,14 +127,11 @@ export default /* html */ `

{{ message.user }}

Avatar -
+

- - - - - +

+ +
+
+ + + + +