ICE 候选者的数量
This commit is contained in:
parent
8bf2f878cb
commit
689154ff5f
@ -19,10 +19,13 @@ export default class ClientList {
|
|||||||
const webrtc_init = async () => {
|
const webrtc_init = async () => {
|
||||||
const webrtc = new RTCPeerConnection({
|
const webrtc = new RTCPeerConnection({
|
||||||
iceServers: [{
|
iceServers: [{
|
||||||
urls: 'turn:satori.love:3478',
|
urls: 'turn:satori.love:3478?transport=udp',
|
||||||
username: 'x-username',
|
username: 'x-username',
|
||||||
credential: 'x-password'
|
credential: 'x-password'
|
||||||
}]
|
}],
|
||||||
|
iceCandidatePoolSize: 10, // 限制 ICE 候选者的数量
|
||||||
|
iceTransportPolicy: 'all', // 使用所有可用的候选者
|
||||||
|
bundlePolicy: 'balanced', // 每種類型的內容建立一個單獨的傳輸
|
||||||
})
|
})
|
||||||
webrtc.ondatachannel = ({ channel }) => {
|
webrtc.ondatachannel = ({ channel }) => {
|
||||||
console.log('对方建立', channel.label, '数据通道')
|
console.log('对方建立', channel.label, '数据通道')
|
||||||
@ -108,14 +111,14 @@ export default class ClientList {
|
|||||||
}
|
}
|
||||||
if (data.type === 'answer') {
|
if (data.type === 'answer') {
|
||||||
//console.log('收到对方 answer', data)
|
//console.log('收到对方 answer', data)
|
||||||
const pc = this.clientlist.find(client => client.id === data.id).webrtc
|
const webrtc = this.clientlist.find(client => client.id === data.id).webrtc
|
||||||
await pc.setRemoteDescription(data.answer)
|
await webrtc.setRemoteDescription(data.answer)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (data.type === 'candidate') {
|
if (data.type === 'candidate') {
|
||||||
console.log(data.name, '发来 candidate 候选通道')
|
console.log(data.name, '发来 candidate 候选通道')
|
||||||
const pc = this.clientlist.find(client => client.id === data.id).webrtc
|
const webrtc = this.clientlist.find(client => client.id === data.id).webrtc
|
||||||
await pc.addIceCandidate(data.candidate)
|
await webrtc.addIceCandidate(data.candidate)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log('收到未知数据:', data)
|
console.log('收到未知数据:', data)
|
||||||
|
Loading…
Reference in New Issue
Block a user