implemented remote streames logic

Signed-off-by: heyhiru <hirentimbadiya74@gmail.com>
Este commit está contenido en:
heyhiru
2023-11-11 20:14:31 +05:30
padre 737b080be0
commit 0068bc39c2
Se han modificado 3 ficheros con 178 adiciones y 19 borrados

Ver fichero

@@ -1,4 +1,4 @@
const { Server} = require('socket.io');
const { Server } = require('socket.io');
const io = new Server(8080, {
cors: true
@@ -22,5 +22,22 @@ io.on("connection", (socket) => {
// emits a 'room:joined' event back to the client
// that just joined the room.
io.to(socket.id).emit("room:join", data);
})
});
socket.on("user:call", ({ to, offer }) => {
io.to(to).emit("incoming:call", { from: socket.id, offer });
});
socket.on("call:accepted", ({ to, ans }) => {
io.to(to).emit("call:accepted", { from: socket.id, ans });
});
socket.on("peer:nego:needed", ({ to, offer }) => {
io.to(to).emit("peer:nego:needed", { from: socket.id, offer });
});
socket.on("peer:nego:done", ({ to, ans }) => {
io.to(to).emit("peer:nego:final", { from: socket.id, ans });
});
})