-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (32 loc) · 820 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const { createServer } = require('http');
const { Server } = require("socket.io");
// const { instrument } = require("@socket.io/admin-ui");
const app = require('express')();
const http = createServer(app);
const io = new Server(http, {
cors: {
origin: '*', // [
// "https://admin.socket.io",
// "http://localhost:5500",
// ],
// credentials: true,
}
});
app.get('/', (_req, res) => res.sendFile(__dirname + '/chat.html'));
io.on("connection", (socket) => {
socket.onAny((event, ...data) => {
console.log(event, ...data);
io.emit(event, ...data);
});
});
// instrument(io, {
// auth: false, // {
// // type: 'basic',
// // username: 'admin',
// // password: process.env.PASSWORD,
// // },
// mode: 'development',
// });
http.listen(3000, () => console.log(
`Starting On Port 3000`
));