LH-276: Add close-producer event handler; Update client #30
27
app.js
27
app.js
@ -389,19 +389,32 @@ peers.on('connection', async (socket) => {
|
||||
try {
|
||||
const callId = socketDetails[socket.id];
|
||||
const socketId = socket.id;
|
||||
let audioParams, videoParams;
|
||||
|
||||
console.log(`[consume] socket ${socket.id} | callId: ${callId}`);
|
||||
console.log(`[consume] socket ${socketId} | callId: ${callId}`);
|
||||
|
||||
if (typeof rtpCapabilities === 'string') rtpCapabilities = JSON.parse(rtpCapabilities);
|
||||
|
||||
callback({
|
||||
videoParams: await consumeVideo({ callId, socketId, rtpCapabilities }),
|
||||
audioParams: await consumeAudio({ callId, socketId, rtpCapabilities }),
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`[consume] | ERROR | callId: ${socketDetails[socket.id]} | error: ${error.message}`);
|
||||
console.error(`[consume] | ERROR | callId: ${callId} | error: ${error.message}`);
|
||||
callback({ params: { error } });
|
||||
}
|
||||
|
||||
try {
|
||||
videoParams = await consumeVideo({ callId, socketId, rtpCapabilities });
|
||||
} catch (error) {
|
||||
console.error(`[consume] | ERROR | videoParams | callId: ${callId} | error: ${error.message}`);
|
||||
}
|
||||
|
||||
try {
|
||||
audioParams = await consumeAudio({ callId, socketId, rtpCapabilities });
|
||||
} catch (error) {
|
||||
console.error(`[consume] | ERROR | audioParams | callId: ${callId} | error: ${error.message}`);
|
||||
}
|
||||
|
||||
callback({
|
||||
videoParams,
|
||||
audioParams,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user
canConsumeAudioReceiver
andcanConsumeAudioInitiator
canConsumeAudio
andcanConsumeVideo
are very similar and very hard to distinguish if something is wrong, extract it in a function and use it in all 4 placesinitCanConsume(producer, callId, rtpCapabilities)
!!
is necessary in all places