mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-27 03:54:09 +00:00
Quit room
This commit is contained in:
parent
f743fc5520
commit
fdc83e12fb
5 changed files with 31 additions and 5 deletions
|
|
@ -85,6 +85,20 @@ func (s *Session) RouteBrowser() {
|
|||
return req
|
||||
})
|
||||
|
||||
browserClient.Receive("quit", func(resp cws.WSPacket) (req cws.WSPacket) {
|
||||
log.Println("Received quit", req)
|
||||
s.GameName = resp.Data
|
||||
s.RoomID = resp.RoomID
|
||||
s.PlayerIndex = resp.PlayerIndex
|
||||
|
||||
room := s.handler.getRoom(s.RoomID)
|
||||
if room.IsPCInRoom(s.peerconnection) {
|
||||
s.handler.detachPeerConn(s.peerconnection)
|
||||
}
|
||||
|
||||
return cws.EmptyPacket
|
||||
})
|
||||
|
||||
browserClient.Receive("start", func(resp cws.WSPacket) (req cws.WSPacket) {
|
||||
s.GameName = resp.Data
|
||||
s.RoomID = resp.RoomID
|
||||
|
|
|
|||
|
|
@ -176,6 +176,9 @@ func (r *Room) removeSession(w *webrtc.WebRTC) {
|
|||
|
||||
// TODO: Reuse for remove Session
|
||||
func (r *Room) IsPCInRoom(w *webrtc.WebRTC) bool {
|
||||
if r == nil {
|
||||
return false
|
||||
}
|
||||
for _, s := range r.rtcSessions {
|
||||
if s.ID == w.ID {
|
||||
return true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue