-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (23 loc) · 753 Bytes
/
Copy pathserver.js
File metadata and controls
30 lines (23 loc) · 753 Bytes
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
const {Server}=require("socket.io");
const io=new Server(3000,{
maxHttpBufferSize: 1e800000000000000,
pingTimeout:30000,
cors: {
origin: "*"
}});
io.on("connection",(socket)=>{
console.log(`New Connection Established with socket id ${socket.id}`);
socket.on("mobile-scan",(room)=>{
socket.join(`${room}`);
console.log(`Scan Received.Room ${room} joined my mobile.`);
io.to(`${room}`).emit("transfer-ready");
});
socket.on("qr-generate",(room)=>{
socket.join(`${room}`);
console.log(`QR Generated.Room ${room} joined by the PC`);
});
socket.on("transfer",({room,message,file,device})=>{
console.log(room,message,file,device);
io.to(`${room}`).emit("receive",message,file,device);
});
});