Skip to content

Commit

Permalink
Check if nil before close WebRTC channels
Browse files Browse the repository at this point in the history
Signed-off-by: billfort <[email protected]>
  • Loading branch information
billfort authored and yilunzhang committed May 10, 2024
1 parent 24ade56 commit 4906690
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions api/webrtc/webrtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,15 @@ func (c *Peer) SetReadLimit(l int64) {
}

func (c *Peer) Close() error {
close(c.OnSdp)
close(c.OnMessage)
close(c.OnOfferConnected)
if c.OnSdp != nil {
close(c.OnSdp)
}
if c.OnMessage != nil {
close(c.OnMessage)
}
if c.OnOfferConnected != nil {
close(c.OnOfferConnected)
}
if c.dc != nil {
if err := c.dc.Close(); err != nil {
return err
Expand Down

0 comments on commit 4906690

Please sign in to comment.