File tree 1 file changed +16
-0
lines changed 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -221,19 +221,35 @@ func (c *Conn) init() error {
221
221
}
222
222
}
223
223
})
224
+
225
+ // These functions need to check if the conn is closed, because they can be
226
+ // called after being closed.
224
227
c .rtc .OnSignalingStateChange (func (signalState webrtc.SignalingState ) {
228
+ if c .isClosed () {
229
+ return
230
+ }
225
231
c .opts .Logger .Debug (context .Background (), "signaling state updated" ,
226
232
slog .F ("state" , signalState ))
227
233
})
228
234
c .rtc .SCTP ().Transport ().OnStateChange (func (dtlsTransportState webrtc.DTLSTransportState ) {
235
+ if c .isClosed () {
236
+ return
237
+ }
229
238
c .opts .Logger .Debug (context .Background (), "dtls transport state updated" ,
230
239
slog .F ("state" , dtlsTransportState ))
231
240
})
232
241
c .rtc .SCTP ().Transport ().ICETransport ().OnSelectedCandidatePairChange (func (candidatePair * webrtc.ICECandidatePair ) {
242
+ if c .isClosed () {
243
+ return
244
+ }
233
245
c .opts .Logger .Debug (context .Background (), "selected candidate pair changed" ,
234
246
slog .F ("local" , candidatePair .Local ), slog .F ("remote" , candidatePair .Remote ))
235
247
})
236
248
c .rtc .OnICECandidate (func (iceCandidate * webrtc.ICECandidate ) {
249
+ if c .isClosed () {
250
+ return
251
+ }
252
+
237
253
if iceCandidate == nil {
238
254
return
239
255
}
You can’t perform that action at this time.
0 commit comments