webSocket สาธุ99
This commit is contained in:
parent
a828693d2e
commit
0f639826c3
3 changed files with 27 additions and 37 deletions
26
src/app.ts
26
src/app.ts
|
|
@ -38,14 +38,14 @@ async function main() {
|
|||
app.use("/", express.static("static"));
|
||||
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
||||
|
||||
app.use((req, res, next) => {
|
||||
console.log(`Request received at: ${req.url}`);
|
||||
next();
|
||||
});
|
||||
// app.use((req, res, next) => {
|
||||
// console.log(`Request received at: ${req.url}`);
|
||||
// next();
|
||||
// });
|
||||
|
||||
app.get('/api', (req, res) => {
|
||||
res.send('API route is working!');
|
||||
});
|
||||
// app.get('/api', (req, res) => {
|
||||
// res.send('API route is working!');
|
||||
// });
|
||||
|
||||
RegisterRoutes(app);
|
||||
|
||||
|
|
@ -139,18 +139,6 @@ async function main() {
|
|||
});
|
||||
});
|
||||
|
||||
wss.clients.forEach((client: any) => {
|
||||
if (client.readyState === WebSocket.OPEN) {
|
||||
const message = "";
|
||||
console.log("📤 Sending data to client:", message);
|
||||
client.send(message, (err:any) => {
|
||||
if (err) {
|
||||
console.error("❌ Error sending message:", err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// ตั้งค่า Express routes
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Hello from Express!');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue