mirror of
https://github.com/openlibrecommunity/olcrtc.git
synced 2026-05-26 07:08:11 +00:00
fix(peer): Add backpressure handling to prevent buffer overflow
This commit is contained in:
@@ -173,6 +173,11 @@ func (p *Peer) Send(data []byte) error {
|
||||
if p.dc == nil || p.dc.ReadyState() != webrtc.DataChannelStateOpen {
|
||||
return fmt.Errorf("datachannel not ready")
|
||||
}
|
||||
|
||||
for p.dc.BufferedAmount() > 1024*1024 {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
}
|
||||
|
||||
return p.dc.Send(data)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user