mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-21 00:59:22 +00:00
Add rooms to handler
This commit is contained in:
parent
8d0dfb1943
commit
041e805963
1 changed files with 2 additions and 4 deletions
|
|
@ -28,8 +28,6 @@ type Room struct {
|
|||
director *emulator.Director
|
||||
}
|
||||
|
||||
var rooms = map[string]*Room{}
|
||||
|
||||
// generateRoomID generate a unique room ID containing 16 digits
|
||||
func generateRoomID() string {
|
||||
roomID := strconv.FormatInt(rand.Int63(), 16)
|
||||
|
|
@ -74,12 +72,12 @@ func (h *Handler) initRoom(roomID, gameName string) *Room {
|
|||
// TODO: If we remove sessions from room anytime a session is closed, we can check if the sessions list is empty or not.
|
||||
func (h *Handler) isRoomRunning(roomID string) bool {
|
||||
// If no roomID is registered
|
||||
if _, ok := rooms[roomID]; !ok {
|
||||
if _, ok := h.rooms[roomID]; !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
// If there is running session
|
||||
for _, s := range rooms[roomID].rtcSessions {
|
||||
for _, s := range h.rooms[roomID].rtcSessions {
|
||||
if !s.IsClosed() {
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue