mirror of
https://github.com/xtr-dev/rondevu-demo.git
synced 2025-12-13 03:53:22 +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 state: ${dc.readyState}`)
|
||||
|
||||
// Small delay to ensure both sides are ready
|
||||
// Longer delay to ensure both sides are ready
|
||||
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)
|
||||
console.log(`📤 Sending identify message...`)
|
||||
const identifyMsg = JSON.stringify({
|
||||
@@ -103,8 +109,17 @@ async function main() {
|
||||
})
|
||||
console.log(` Message:`, identifyMsg)
|
||||
dc.send(identifyMsg)
|
||||
console.log(` ✓ Identify message sent`)
|
||||
}, 100)
|
||||
console.log(` ✓ Identify message sent, bufferedAmount: ${dc.bufferedAmount}`)
|
||||
}, 500)
|
||||
}
|
||||
|
||||
dc.onclose = () => {
|
||||
console.log(' ❌ Data channel closed!')
|
||||
}
|
||||
|
||||
dc.onerror = (error) => {
|
||||
console.error('❌ Data channel error:', error)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
dc.onmessage = (event) => {
|
||||
|
||||
Reference in New Issue
Block a user