You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
550 B

5 months ago
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. const ws = new WebSocket("ws://localhost:3003");
  11. ws.onopen = () => {
  12. console.log("Connected to server");
  13. ws.send("Hello from client!");
  14. };
  15. ws.onmessage = event => {
  16. console.log(`Message from server: ${event.data}`);
  17. };
  18. ws.onclose = () => {
  19. console.log("Disconnected from server");
  20. };
  21. </script>
  22. </body>
  23. </html>