UNPKG

rtc-link

Version:

A library for managing WebRTC connections with multiplexed streams, anti-glare handling, and streamlined data channel setup.

10 lines (9 loc) 470 B
import {defaultIfEmpty, firstValueFrom, map, take, takeUntil} from "rxjs"; import {listenAndConnectionAndRead$, withEncoding} from "rxprotoplex"; import {CHANNEL} from "./constants.js"; export const waitForAnswer = async (plex, close$) => { return firstValueFrom( listenAndConnectionAndRead$(plex, CHANNEL.WEBRTC_ANSWER, withEncoding("json", {unique: false})) .pipe(takeUntil(close$), take(1), map(o => o?.data), defaultIfEmpty(false)) ); };