UNPKG

@4players/odin

Version:

A cross-platform SDK enabling developers to integrate real-time VoIP chat technology into their projects

41 lines (40 loc) 1.26 kB
import { sleep } from './utils/helpers'; const audioOutputs = new Map(); async function main() { emitActivity().catch(console.error); emitPowerLevel().catch(console.error); emitJitterStats().catch(console.error); } export function registerAudioOutput(output, handler, room) { audioOutputs.set(output, { handler, room }); } export function unregisterAudioOutput(output) { audioOutputs.delete(output); } async function emitActivity(interval = 100) { while (true) { await sleep(interval); for (const [media, data] of audioOutputs) { data.handler('Activity'); } } } async function emitPowerLevel(interval = 500) { while (true) { await sleep(interval); for (const [media, data] of audioOutputs) { data.handler('PowerLevel'); } } } async function emitJitterStats(interval = 1000) { while (true) { await sleep(interval); for (const [media, data] of audioOutputs) { data.handler('JitterStats'); } } } main().catch(console.error); // I create a Capture that's not related to a room // The capture gets linked to a room, the function that links (room.addAudioInput) needs to tell this module, that capture xyz was linked