mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-22 17:47:11 +00:00
client closes peerconnection
This commit is contained in:
parent
8c4f6f624e
commit
2a782100a0
4 changed files with 25 additions and 5 deletions
|
|
@ -107,10 +107,22 @@ func (h *Handler) WS(w http.ResponseWriter, r *http.Request) {
|
|||
}, nil)
|
||||
|
||||
wssession.BrowserClient.Listen()
|
||||
|
||||
// TODO: Use callback
|
||||
// listen to socket done to close peerconnection
|
||||
go func() {
|
||||
for {
|
||||
<-client.Done
|
||||
h.detachPeerConn(wssession.peerconnection)
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
// Detach peerconnection detach/remove a peerconnection from current room
|
||||
func (h *Handler) detachPeerConn(pc *webrtc.WebRTC) {
|
||||
log.Println("Detach peerconnection")
|
||||
roomID := pc.RoomID
|
||||
room := h.getRoom(roomID)
|
||||
if room == nil {
|
||||
|
|
|
|||
|
|
@ -171,12 +171,15 @@ func (r *Room) removeSession(w *webrtc.WebRTC) {
|
|||
}
|
||||
|
||||
func (r *Room) Close() {
|
||||
log.Println("Closing room", r.ID)
|
||||
if r.Done == false {
|
||||
log.Println("Closing room", r.ID)
|
||||
log.Println("Closing director of room ", r.ID)
|
||||
close(r.director.Done)
|
||||
log.Println("Closing input of room ", r.ID)
|
||||
close(r.inputChannel)
|
||||
r.Done = true
|
||||
}
|
||||
r.Done = true
|
||||
log.Println("Closing director of room ", r.ID)
|
||||
close(r.director.Done)
|
||||
log.Println("Closing input of room ", r.ID)
|
||||
close(r.inputChannel)
|
||||
// Close here is a bit wrong because this read channel
|
||||
//close(r.imageChannel)
|
||||
//close(r.audioChannel)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue