Skip to content

Commit 462290e

Browse files
committed
add deebounce
1 parent a183567 commit 462290e

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/pion/ion-sfu
33
go 1.13
44

55
require (
6+
github.com/bep/debounce v1.2.0
67
github.com/gammazero/deque v0.0.0-20201010052221-3932da5530cc
78
github.com/golang/protobuf v1.4.3 // indirect
89
github.com/gorilla/websocket v1.4.2

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV
3030
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
3131
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
3232
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
33+
github.com/bep/debounce v1.2.0 h1:wXds8Kq8qRfwAOpAxHrJDbCXgC5aHSzgQb/0gKsHQqo=
34+
github.com/bep/debounce v1.2.0/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
3335
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
3436
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
3537
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=

pkg/webrtctransport.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package sfu
22

33
import (
44
"sync"
5+
"time"
56

7+
"github.com/bep/debounce"
68
"github.com/gammazero/deque"
7-
89
"github.com/lucsky/cuid"
910
log "github.com/pion/ion-log"
1011
"github.com/pion/sdp/v3"
@@ -219,7 +220,10 @@ func (p *WebRTCTransport) OnICECandidate(f func(c *webrtc.ICECandidate)) {
219220

220221
// OnNegotiationNeeded handler
221222
func (p *WebRTCTransport) OnNegotiationNeeded(f func()) {
222-
p.negotiate = f
223+
debounced := debounce.New(100 * time.Millisecond)
224+
p.negotiate = func() {
225+
debounced(f)
226+
}
223227
}
224228

225229
// OnTrack handler

0 commit comments

Comments
 (0)