问题:我把一个sdp发给多个人,多个人都能用吗?
答:只能一个人用,用了之后其他人就不能用了。
问题:Ice收集时间问题?
答:默认最大5秒,有个5秒的超时检查,超时强行置位完成。
this._pc = new RTCPeerConnection(config);
this._pc.onicecandidate = event => {
// ...
this._startIceCompleteTimeout(5 * 1000)
}
问题:用户直接关闭浏览器,如何检查datachannel,peer的关闭和close?
答:有个定时任务去check,默认5秒检查datachannel状态。
this._closingInterval = setInterval(() => {
if (this._channel && this._channel.readyState === 'closing') {
isClosing = true
this.emit('close')
} else {
isClosing = false
}
}, 5 * 1000)
this._pc.onconnectionstatechange = () => {
if (this._pc.connectionState === 'failed') {
this.destroy(errCode(new Error('Connection failed.'), 'ERR_CONNECTION_FAILURE'))
}
}
问题:A有防火墙,B没防火墙 在同一个交换机下。A无法充当offer发起者,但是也能与B peer,因为B可以当offer发起者,即A不能为master如下图。
这里A和B都可以通过datachannel发送数据。
问题:信令服务 定时 30 * 1000 // 30 seconds 发送 offer,服务端 配置的是 120秒,最终是120s
问题:offer有效期是多少时间?默认配置的是50秒。
function generateOffer () {
const offerId = randombytes(20).toString('hex')
debug('creating peer (from _generateOffers)')
const peer = self.peers[offerId] = self._createPeer({
initiator: true })
peer.once('signal', offer => {
offers.push({
offer,
offer_id: common.hexToBinary(offerId)
})
checkDone()
})
peer.trackerTimeout = setTimeout(() => {
debug('tracker timeout: destroying peer')
peer.trackerTimeout = null
delete self.peers[offerId]
peer.destroy()
}, 50 * 1000)
}