Skip to content

Commit

Permalink
Refactor P2PVideoDemo component to filter out non-main streamType in …
Browse files Browse the repository at this point in the history
…onPeerConnect and onPeerClose event handlers (#399)
  • Loading branch information
DimaDemchenko authored Jul 19, 2024
1 parent cb66421 commit 4cf28e8
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,16 @@ export const P2PVideoDemo = ({ debugToolsEnabled = false }: DemoProps) => {
}, []);

const onPeerConnect = useCallback((params: PeerDetails) => {
if (params.streamType !== "main") return;

setPeers((peers) => {
return [...peers, params.peerId];
});
}, []);

const onPeerClose = useCallback((params: PeerDetails) => {
if (params.streamType !== "main") return;

setPeers((peers) => {
return peers.filter((peer) => peer !== params.peerId);
});
Expand Down

0 comments on commit 4cf28e8

Please sign in to comment.