package cache import ( "sync" "clickandjoin.app/websocketserver/modules/structs" ) var socketClients = make(map[string]*structs.SocketClient) var mu sync.RWMutex func AddSocketClient(wsSessionId string, socketClient *structs.SocketClient) { mu.Lock() socketClients[wsSessionId] = socketClient mu.Unlock() } func DeleteClient(wsSessionId string) { mu.Lock() delete(socketClients, wsSessionId) mu.Unlock() } func GetSocketClients() map[string]*structs.SocketClient { mu.RLock() defer mu.RUnlock() return socketClients } func GetSocketClient(wsSessionId string) (socketClient *structs.SocketClient, ok bool) { mu.RLock() defer mu.RUnlock() client, ok := socketClients[wsSessionId] return client, ok }