From bc97bc1e53382855d46f32d3ee58a73a9f8318a5 Mon Sep 17 00:00:00 2001 From: giongto35 Date: Fri, 10 May 2019 01:51:39 +0800 Subject: [PATCH] add recover for inputchannel --- handler/room/room.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/handler/room/room.go b/handler/room/room.go index 7d1690f1..20eda172 100644 --- a/handler/room/room.go +++ b/handler/room/room.go @@ -108,6 +108,12 @@ func (r *Room) AddConnectionToRoom(peerconnection *webrtc.WebRTC, playerIndex in } func (r *Room) startWebRTCSession(peerconnection *webrtc.WebRTC, playerIndex int) { + defer func() { + if r := recover(); r != nil { + fmt.Println("Recovered when sent to close inputChannel") + } + }() + for { select { case <-r.Done: @@ -140,10 +146,6 @@ func (r *Room) startWebRTCSession(peerconnection *webrtc.WebRTC, playerIndex int func (r *Room) CleanSession(peerconnection *webrtc.WebRTC) { r.removeSession(peerconnection) - // TODO: Clean all channels - //close(peerconnection.ImageChannel) - //close(peerconnection.AudioChannel) - //close(peerconnection.InputChannel) } func (r *Room) removeSession(w *webrtc.WebRTC) {