updated remove func name
parent
003c9d3eb3
commit
8bade7992d
|
@ -21,7 +21,7 @@ func DeleteClientByConn(conn *websocket.Conn) {
|
|||
|
||||
for i := 0; i < len(socketClients); i++ {
|
||||
if socketClients[i].Conn == conn {
|
||||
socketClients = remove(socketClients, i)
|
||||
socketClients = removeSocketClient(socketClients, i)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ func DeleteClientByConn(conn *websocket.Conn) {
|
|||
mu.Unlock()
|
||||
}
|
||||
|
||||
func remove(s []*structs.SocketClient, i int) []*structs.SocketClient {
|
||||
func removeSocketClient(s []*structs.SocketClient, i int) []*structs.SocketClient {
|
||||
return append(s[:i], s[i+1:]...)
|
||||
}
|
||||
|
||||
|
@ -39,26 +39,3 @@ func GetSocketClients() []*structs.SocketClient {
|
|||
|
||||
return socketClients
|
||||
}
|
||||
|
||||
/*
|
||||
func GetSocketClient(sessionId string) (socketClient *structs.SocketClient, ok bool) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
|
||||
client, ok := socketClients[sessionId]
|
||||
|
||||
return client, ok
|
||||
}
|
||||
|
||||
func GetSocketClientByConn(conn *websocket.Conn) (socketClient *structs.SocketClient, err error) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
|
||||
for _, client := range socketClients {
|
||||
if client.Conn == conn {
|
||||
return client, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, errors.New("Failed to find socket client by ws conn")
|
||||
}*/
|
||||
|
|
Loading…
Reference in New Issue