mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-08-02 14:52:26 +00:00
Fix dangling rooms when multiplaying
This commit is contained in:
parent
a8d47fd1bf
commit
7977bce8a3
2 changed files with 3 additions and 2 deletions
|
|
@ -162,8 +162,8 @@ func (c *coordinator) HandleGameStart(rq api.StartGameRequest[com.Uid], w *Worke
|
|||
func (c *coordinator) HandleTerminateSession(rq api.TerminateSessionRequest[com.Uid], w *Worker) {
|
||||
if user := w.router.FindUser(rq.Id); user != nil {
|
||||
w.router.Remove(user)
|
||||
c.log.Debug().Msgf(">>> users: %v", w.router.Users())
|
||||
user.Disconnect()
|
||||
w.router.SetRoom(nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ func (c *coordinator) HandleTerminateSession(rq api.TerminateSessionRequest[com.
|
|||
func (c *coordinator) HandleQuitGame(rq api.GameQuitRequest[com.Uid], w *Worker) {
|
||||
if user := w.router.FindUser(rq.Id); user != nil {
|
||||
w.router.Remove(user)
|
||||
w.router.SetRoom(nil)
|
||||
c.log.Debug().Msgf(">>> users: %v", w.router.Users())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ func (r *Router[T]) FindRoom(id string) *Room[T] {
|
|||
func (r *Router[T]) Remove(user T) {
|
||||
if left := r.users.RemoveL(user); left == 0 {
|
||||
r.Close()
|
||||
r.SetRoom(nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue