Don aikawa da karɓar rafukan watsa labarai tare da Mediasoup-client, kuna iya bin waɗannan matakan:
Fara Transport
Da farko, fara Transport
abu ta amfani da hanyar device.createSendTransport()
ko device.createRecvTransport()
hanya.
const transport = await device.createSendTransport({
// Transport configuration
});
Ƙirƙiri Producer
Da zarar kana da Transport
abin, za ka iya ƙirƙirar Producer
don aika rafukan mai jarida zuwa uwar garken. Yi amfani da transport.produce()
hanyar kuma saka nau'in rafin mai jarida(misali, 'audio', 'bidiyo', 'bayanai') da duk wani tsarin da ake buƙata.
const producer = await transport.produce({
kind: 'video',
// Producer configuration
});
Ƙirƙiri Consumer
Don karɓar rafukan mai jarida daga uwar garken, kuna buƙatar ƙirƙirar Consumer
. Yi amfani da transport.consume()
hanyar kuma saka saitin don Consumer
.
const consumer = await transport.consume({
// Consumer configuration
});
Aika da Karɓi Bayanai
Abun Mai samarwa yana ba da hanyoyin aika bayanai zuwa uwar garken, kamar producer.send()
aika bayanan bidiyo ko sauti. Hakanan zaka iya sauraron abubuwan da suka faru kamar 'transport', 'producer', ko makamantan abubuwan da suka faru don gudanar da aika bayanai.
Abun mai amfani yana ba da hanyoyin karɓar bayanai daga uwar garken, kamar consumer.on('transport',() => { /* Handle received data */ })
. Hakanan zaka iya sauraron 'mabukaci' ko makamantan abubuwan da suka faru don gudanar da karɓar bayanai.
Lura cewa tsarin aikawa da karɓar rafukan watsa labarai na iya zama mai rikitarwa dangane da buƙatu da daidaitawar aikace-aikacenku. Koma zuwa Mediasoup-client takaddun don ƙarin bayani kan samuwa hanyoyin da abubuwan da suka faru don keɓance aikawa da karɓar rafukan kafofin watsa labarai gwargwadon bukatunku.