Create WebSocket Server
- Created a WebSocket server with connection handling and message broadcasting - Added frontend files including HTML, TypeScript, and CSS for a WebSocket test client - Configured package.json for both server and frontend with necessary scripts and dependencies - Introduced Prettier configuration for code formatting - Established a basic structure for handling WebSocket connections and messages
This commit is contained in:
13
frontend/web/src/main.ts
Normal file
13
frontend/web/src/main.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
const webSocket = new WebSocket('http://localhost:3000');
|
||||
|
||||
webSocket.onerror = (e: Event) => {
|
||||
console.error(`${new Date().toISOString()} [WebSocket] error [%o]`, e);
|
||||
};
|
||||
|
||||
webSocket.onopen = () => {
|
||||
console.log(`${new Date().toISOString()} [WebSocket] open`);
|
||||
};
|
||||
|
||||
webSocket.onmessage = () => {
|
||||
console.log(`${new Date().toISOString()} [WebSocket] message!`);
|
||||
};
|
||||
4
frontend/web/src/style.css
Normal file
4
frontend/web/src/style.css
Normal file
@@ -0,0 +1,4 @@
|
||||
body {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
1
frontend/web/src/vite-env.d.ts
vendored
Normal file
1
frontend/web/src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
Reference in New Issue
Block a user