From a6879bd3208d09fce5365e7bfb293a7986795d29 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 26 Feb 2024 12:59:15 +0100 Subject: [PATCH] chore: update playground --- examples/h3/public/index.html | 184 ++++++++++++++++++++++----------- playground/_index.html.ts | 187 +++++++++++++++++++++++----------- playground/_shared.ts | 21 ++++ 3 files changed, 274 insertions(+), 118 deletions(-) diff --git a/examples/h3/public/index.html b/examples/h3/public/index.html index 6009275..be8cd50 100644 --- a/examples/h3/public/index.html +++ b/examples/h3/public/index.html @@ -2,89 +2,157 @@ CrossWS Test Page - - - - -

WebSocket Test Page

- -
- - - -
+ + + + + +
+ +
+
+
+

{{ message.user }}

+
+ Avatar +
+

{{ message.text }}

+
+
+

{{ message.date }}

+
+
+
+ + +
+ + + + + +
+
diff --git a/playground/_index.html.ts b/playground/_index.html.ts index 79dee98..3e6f6b4 100644 --- a/playground/_index.html.ts +++ b/playground/_index.html.ts @@ -2,90 +2,157 @@ export default /* html */ ` CrossWS Test Page - - - - -

WebSocket Test Page

- -
- - - -
+ + + + + +
+ +
+
+
+

{{ message.user }}

+
+ Avatar +
+

{{ message.text }}

+
+
+

{{ message.date }}

+
+
+
+ + +
+ + + + + +
+
- -`; +`; diff --git a/playground/_shared.ts b/playground/_shared.ts index 7b1d629..b784d46 100644 --- a/playground/_shared.ts +++ b/playground/_shared.ts @@ -33,6 +33,27 @@ export function createDemo>( }, }); + // open(peer) { + // // Send welcome to the new client + // peer.send("Welcome to the server!"); + + // // Join new client to the "chat" channel + // peer.subscribe("chat"); + + // // Notify every other connected client + // peer.publish("chat", `[system] ${peer} joined!`); + // }, + + // message(peer, message) { + // // The server re-broadcasts incoming messages to everyone + // peer.publish("chat", `[${peer}] ${message}`); + // }, + + // close(peer) { + // peer.publish("chat", `[system] ${peer} has left the chat!`); + // peer.unsubscribe("chat"); + // }, + const resolve: ResolveHooks = (info) => { return { open: (peer) => {