package data import ( "github.com/ParadoxPixel/ThemePark-Websocket/objects" "sync" ) var serverMux sync.RWMutex var servers = make(map[string]*objects.Server) func AddServer(server *objects.Server) { serverMux.Lock() if _,ok := servers[server.ID]; !ok { servers[server.ID] = server } serverMux.Unlock() } func CanServer(server string) bool { if server == "" || server == "null" { return false } if ok, _ := HasServer(server); ok { return false } else { return true } } func GetServer(server string) *objects.Server { serverMux.Lock() val,ok := servers[server] serverMux.Unlock() if ok { return val } else { return nil } } func HasServer(publicKey string) (bool, *objects.Server) { serverMux.Lock() val,ok := servers[publicKey] serverMux.Unlock() return ok, val } func RemoveServer(session string) { serverMux.Lock() delete(servers, session) serverMux.Unlock() }