-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
Hello,
In my app, I have several rooms to talk in live mode, a user comes to one of the rooms and now wants to leave and connect to new room OR completly leave the connection, how can I achieve this?
I couldn't close the current connection, poof
Please help
Here is my code:
let socket = io(`https://${url}`);
const peerServer = new Peer(undefined, {
host: url,
secure: true,
port: '443',
path: '/peerjs',
config: {
debug: 3,
iceServers: [
{urls: ['stun:stun1.l.google.com:19302']},
{
username: 'epz-hBZGVrdW5sZTE=',
credential: 'c531d3-a2e6-0242a140004',
credentialType: 'password',
urls: [
'turn:us-turn4.xirsys.com:80?transport=udp',
'turn:us-turn4.xirsys.com:3478?transport=udp',
'turn:us-turn4.xirsys.com:80?transport=tcp',
'turn:us-turn4.xirsys.com:3478?transport=tcp',
'turns:us-turn4.xirsys.com:443?transport=tcp',
'turns:us-turn4.xirsys.com:5349?transport=tcp',
],
},
],
},
});
peerServer.on('open', (userId: any) => {
let roomId = '7b22dc91-3638-4964-95f2-d32b61541b66';
socket.emit('join-room', roomId, userId);
});
socket.on('user-connected', (localPeer: any) => {
const call = peerServer.call(localPeer, stream);
call.on('stream', (audioStream: any) => {
setStreams([...streams, audioStream]);
});
});
peerServer.on('call', (call: any) => {
call.answer(stream);
call.on('stream', (userStream: any) => {
setUserStreams([...userStreams, userStream]);
});
});
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels