mirror of
https://github.com/xtr-dev/rondevu-demo.git
synced 2025-12-15 12:33:23 +00:00
Add data channel state monitoring and increase send delay
- Increase delay to 500ms before sending identify - Monitor channel state before sending - Log bufferedAmount after send - Add onclose handler for debugging
This commit is contained in:
@@ -93,8 +93,14 @@ async function main() {
|
|||||||
console.log(' ✓ Data channel opened!')
|
console.log(' ✓ Data channel opened!')
|
||||||
console.log(` Data channel state: ${dc.readyState}`)
|
console.log(` Data channel state: ${dc.readyState}`)
|
||||||
|
|
||||||
// Small delay to ensure both sides are ready
|
// Longer delay to ensure both sides are ready
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
console.log(` Data channel state before send: ${dc.readyState}`)
|
||||||
|
if (dc.readyState !== 'open') {
|
||||||
|
console.error(` ❌ Data channel not open: ${dc.readyState}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Send identify message (demo protocol)
|
// Send identify message (demo protocol)
|
||||||
console.log(`📤 Sending identify message...`)
|
console.log(`📤 Sending identify message...`)
|
||||||
const identifyMsg = JSON.stringify({
|
const identifyMsg = JSON.stringify({
|
||||||
@@ -103,8 +109,17 @@ async function main() {
|
|||||||
})
|
})
|
||||||
console.log(` Message:`, identifyMsg)
|
console.log(` Message:`, identifyMsg)
|
||||||
dc.send(identifyMsg)
|
dc.send(identifyMsg)
|
||||||
console.log(` ✓ Identify message sent`)
|
console.log(` ✓ Identify message sent, bufferedAmount: ${dc.bufferedAmount}`)
|
||||||
}, 100)
|
}, 500)
|
||||||
|
}
|
||||||
|
|
||||||
|
dc.onclose = () => {
|
||||||
|
console.log(' ❌ Data channel closed!')
|
||||||
|
}
|
||||||
|
|
||||||
|
dc.onerror = (error) => {
|
||||||
|
console.error('❌ Data channel error:', error)
|
||||||
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.onmessage = (event) => {
|
dc.onmessage = (event) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user