You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

31 lines
491 B

package ws
import (
"sync"
)
type Room struct {
Id string
clients map[string]*Client
rwmux *sync.RWMutex
}
func NewRoom(id string) *Room {
room := new(Room)
room.Id = id
room.clients = make(map[string]*Client, 0)
room.rwmux = new(sync.RWMutex)
return room
}
func (t *Room) Len() int {
t.rwmux.RLock()
defer t.rwmux.RUnlock()
return len(t.clients)
}
func (t *Room) DeleteClient(clientId string) {
t.rwmux.Lock()
defer t.rwmux.Unlock()
delete(t.clients, clientId)
}