Added removal of streams whe they close or error
This commit is contained in:
parent
91c7c9f9ad
commit
5042f203cd
@ -89,6 +89,14 @@ function useSession(onConnectionOpen, onConnectionSync) {
|
||||
call.on("stream", remoteStream => {
|
||||
addStream(remoteStream, call.peer);
|
||||
});
|
||||
function removeStream() {
|
||||
setStreams(prevStreams => {
|
||||
const { [call.peer]: old, ...rest } = prevStreams;
|
||||
return rest;
|
||||
});
|
||||
}
|
||||
call.on("close", removeStream);
|
||||
call.on("error", removeStream);
|
||||
}
|
||||
|
||||
if (!peer) {
|
||||
|
Loading…
Reference in New Issue
Block a user