Clean room with no sessions

This commit is contained in:
giongto35 2019-04-10 03:33:21 +08:00
parent f5864169d8
commit a6b6bd2ccd
3 changed files with 7 additions and 2 deletions

View file

@ -227,12 +227,14 @@ func fanoutScreen(imageChannel chan *image.RGBA, roomID string) {
// encode frame
// fanout imageChannel
if webRTC.IsConnected() {
// NOTE: can block here
webRTC.ImageChannel <- yuv
}
isRoomRunning = true
}
if isRoomRunning == false {
log.Println("Closed room", roomID)
rooms[roomID].closedChannel <- true
}
}

View file

@ -69,7 +69,6 @@ L:
select {
// if there is event from close channel => the game is ended
case <-d.closedChannel:
log.Println("Closed game")
break L
default:
}

View file

@ -185,6 +185,10 @@ func (w *WebRTC) StartClient(remoteSession string, width, height int) (string, e
// Input is key state, represented as binary string, 1001011. We compress it to binary number
w.InputChannel <- i
})
d.OnClose(func() {
w.isClosed = true
})
})
offer := webrtc.SessionDescription{}
@ -224,7 +228,7 @@ func (w *WebRTC) StopClient() {
w.connection.Close()
}
w.connection = nil
w.isClosed = true
//w.isClosed = true
}
// IsConnected comment