Log data channel close and errors. (#2025)
This commit is contained in:
+25
-16
@@ -704,9 +704,9 @@ func (t *PCTransport) maybeNotifyFullyEstablished() {
|
|||||||
|
|
||||||
func (t *PCTransport) isFullyEstablished() bool {
|
func (t *PCTransport) isFullyEstablished() bool {
|
||||||
t.lock.RLock()
|
t.lock.RLock()
|
||||||
fullyEstablished := t.reliableDCOpened && t.lossyDCOpened && !t.connectedAt.IsZero()
|
defer t.lock.RUnlock()
|
||||||
t.lock.RUnlock()
|
|
||||||
return fullyEstablished
|
return t.reliableDCOpened && t.lossyDCOpened && !t.connectedAt.IsZero()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *PCTransport) SetPreferTCP(preferTCP bool) {
|
func (t *PCTransport) SetPreferTCP(preferTCP bool) {
|
||||||
@@ -813,22 +813,27 @@ func (t *PCTransport) CreateDataChannel(label string, dci *webrtc.DataChannelIni
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
reliableDCReadyHandler := func() {
|
dcReadyHandler := func() {
|
||||||
t.params.Logger.Debugw("reliable data channel open")
|
|
||||||
t.lock.Lock()
|
t.lock.Lock()
|
||||||
t.reliableDCOpened = true
|
switch dc.Label() {
|
||||||
|
case ReliableDataChannel:
|
||||||
|
t.reliableDCOpened = true
|
||||||
|
|
||||||
|
case LossyDataChannel:
|
||||||
|
t.lossyDCOpened = true
|
||||||
|
}
|
||||||
t.lock.Unlock()
|
t.lock.Unlock()
|
||||||
|
t.params.Logger.Debugw(dc.Label() + " data channel open")
|
||||||
|
|
||||||
t.maybeNotifyFullyEstablished()
|
t.maybeNotifyFullyEstablished()
|
||||||
}
|
}
|
||||||
|
|
||||||
lossyDCReadyHanlder := func() {
|
dcCloseHandler := func() {
|
||||||
t.params.Logger.Debugw("lossy data channel open")
|
t.params.Logger.Infow(dc.Label() + " data channel close")
|
||||||
t.lock.Lock()
|
}
|
||||||
t.lossyDCOpened = true
|
|
||||||
t.lock.Unlock()
|
|
||||||
|
|
||||||
t.maybeNotifyFullyEstablished()
|
dcErrorHandler := func(err error) {
|
||||||
|
t.params.Logger.Errorw(dc.Label()+" data channel close", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.lock.Lock()
|
t.lock.Lock()
|
||||||
@@ -836,17 +841,21 @@ func (t *PCTransport) CreateDataChannel(label string, dci *webrtc.DataChannelIni
|
|||||||
case ReliableDataChannel:
|
case ReliableDataChannel:
|
||||||
t.reliableDC = dc
|
t.reliableDC = dc
|
||||||
if t.params.DirectionConfig.StrictACKs {
|
if t.params.DirectionConfig.StrictACKs {
|
||||||
t.reliableDC.OnOpen(reliableDCReadyHandler)
|
t.reliableDC.OnOpen(dcReadyHandler)
|
||||||
} else {
|
} else {
|
||||||
t.reliableDC.OnDial(reliableDCReadyHandler)
|
t.reliableDC.OnDial(dcReadyHandler)
|
||||||
}
|
}
|
||||||
|
t.reliableDC.OnClose(dcCloseHandler)
|
||||||
|
t.reliableDC.OnError(dcErrorHandler)
|
||||||
case LossyDataChannel:
|
case LossyDataChannel:
|
||||||
t.lossyDC = dc
|
t.lossyDC = dc
|
||||||
if t.params.DirectionConfig.StrictACKs {
|
if t.params.DirectionConfig.StrictACKs {
|
||||||
t.lossyDC.OnOpen(lossyDCReadyHanlder)
|
t.lossyDC.OnOpen(dcReadyHandler)
|
||||||
} else {
|
} else {
|
||||||
t.lossyDC.OnDial(lossyDCReadyHanlder)
|
t.lossyDC.OnDial(dcReadyHandler)
|
||||||
}
|
}
|
||||||
|
t.lossyDC.OnClose(dcCloseHandler)
|
||||||
|
t.lossyDC.OnError(dcErrorHandler)
|
||||||
default:
|
default:
|
||||||
t.params.Logger.Errorw("unknown data channel label", nil, "label", dc.Label())
|
t.params.Logger.Errorw("unknown data channel label", nil, "label", dc.Label())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user