aidk
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
package main
|
||||
|
||||
import "sync"
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
mu sync.RWMutex
|
||||
Clients = make(map[uint32]Client)
|
||||
clients = make(map[uint32]Client)
|
||||
ChatGroups = make(map[uint32]ChatGroup)
|
||||
ClientsMap = make(map[uint32]map[uint32]*Client)
|
||||
)
|
||||
@@ -23,7 +26,7 @@ func RemoveGroupFromCache(chatGroup *ChatGroup) {
|
||||
delete(ClientsMap, chatGroup.Id)
|
||||
}
|
||||
|
||||
func AddAuthenticatedClientToCache(client *Client) {
|
||||
func AddClientConnectionsToCache(client *Client) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
for _, groupIn := range client.Groups {
|
||||
@@ -33,7 +36,7 @@ func AddAuthenticatedClientToCache(client *Client) {
|
||||
}
|
||||
}
|
||||
|
||||
func RemoveClientFromCache(client *Client) {
|
||||
func RemoveClientConnectionsToCache(client *Client) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
for _, groupIn := range client.Groups {
|
||||
@@ -43,6 +46,10 @@ func RemoveClientFromCache(client *Client) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetClientData(uint32 *Client) {
|
||||
|
||||
func GetClientFromId(id uint32) (*Client, error) {
|
||||
client, ok := &clients[id]
|
||||
if !ok {
|
||||
return nil, errors.New("No such user")
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user