|
@@ -21,14 +21,13 @@ const io = new Server(server, {
|
|
|
});
|
|
|
|
|
|
io.on('connection', (socket) => {
|
|
|
- console.log(`User Connected: ${socket.id}`);
|
|
|
-
|
|
|
- socket.on('join_room', (data) => {
|
|
|
- socket.join(data);
|
|
|
+ console.log('connect', socket.id);
|
|
|
+ socket.emit('me', socket.id);
|
|
|
+ socket.on('call', ({ userToCall, signalData, from, name }) => {
|
|
|
+ io.to(userToCall).emit('call', { signal: signalData, from, name });
|
|
|
});
|
|
|
-
|
|
|
- socket.on('send_message', (data) => {
|
|
|
- socket.to(data.room).emit('receive_message', data);
|
|
|
+ socket.on('answer', (data) => {
|
|
|
+ io.to(data.to).emit('accepted', { signal: data.signal });
|
|
|
});
|
|
|
});
|
|
|
|