fix bugs with websocket reconnection, don't re-use redis sinks (#22)

This commit is contained in:
David Zhao
2021-02-15 17:57:01 -08:00
committed by GitHub
parent 9466bc01ed
commit 99baeb38e4
11 changed files with 268 additions and 219 deletions
+4 -2
View File
@@ -8,6 +8,7 @@ import (
"github.com/bep/debounce"
"github.com/pion/webrtc/v3"
"github.com/livekit/livekit-server/pkg/logger"
"github.com/livekit/livekit-server/proto/livekit"
)
@@ -111,6 +112,7 @@ func (t *PCTransport) SetRemoteDescription(sd webrtc.SessionDescription) error {
state := t.negotiationState.Load().(int)
t.negotiationState.Store(negotiationStateNone)
if state == negotiationStateServer && t.onNegotiation != nil {
logger.Debugw("negotiating again")
// need to negotiate again
t.negotiate()
}
@@ -126,14 +128,14 @@ func (t *PCTransport) negotiate() {
t.debouncedNegotiate(func() {
state := t.negotiationState.Load().(int)
// when there's an ongoing negotiation, let it finish and not disrupt its state
if state != negotiationStateNone {
if state == negotiationStateClient {
logger.Debugw("skipping negotiation, trying again later")
t.negotiationState.Store(negotiationStateServer)
return
}
if t.onNegotiation != nil {
t.onNegotiation()
// indicate waiting for client
t.negotiationState.Store(negotiationStateClient)
}