mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-23 18:46:11 +00:00
Clean room with no sessions
This commit is contained in:
parent
f5864169d8
commit
a6b6bd2ccd
3 changed files with 7 additions and 2 deletions
2
main.go
2
main.go
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue