From d1c68f90ea53ebb5fa5daddd9e51a6893617d936 Mon Sep 17 00:00:00 2001 From: haoyanbin <605649647@qq.com> Date: Wed, 11 Jan 2023 13:43:27 +0800 Subject: [PATCH] Redis --- pool/client.go | 2 +- pool/publicApi.go | 11 ++++++----- ws_server.go | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pool/client.go b/pool/client.go index faf2d45..89480b4 100755 --- a/pool/client.go +++ b/pool/client.go @@ -143,7 +143,7 @@ func (c *Client) readPump() { close(c.sendPing) c.grpool.Close() c.hub.RemoveClient(c) - DelClient(c.Id,c.User) + DelClient(c.User) dump() }() Loop: diff --git a/pool/publicApi.go b/pool/publicApi.go index ec5340f..03eabab 100755 --- a/pool/publicApi.go +++ b/pool/publicApi.go @@ -69,7 +69,8 @@ func NewClient(conf *Config) *Client { client.OnPing(nil) client.OnPong(nil) wsSever.hub.AddClient(client) - AppendClient(client.Id, client.User, string(SerializeJson(conf))) + //AppendUser(client.Id, string(SerializeJson(conf))) + AppendClient(client.User, string(SerializeJson(conf))) return client } @@ -507,13 +508,13 @@ func DelConversation(conversationId int) { return } -func AppendClient(clientId, clientUser, data string) { - Redis.HSet(cliKey+":"+clientId, clientUser, data) +func AppendClient(client, data string) { + Redis.HSet(cliKey, client, data) return } -func DelClient(clientId, clientUser string) { - Redis.HDel(cliKey+":"+clientId, clientUser) +func DelClient(client string) { + Redis.HDel(cliKey, client) return } diff --git a/ws_server.go b/ws_server.go index 9dae5e3..8a8feb3 100755 --- a/ws_server.go +++ b/ws_server.go @@ -154,7 +154,7 @@ func ws(w http.ResponseWriter, r *http.Request) { pool.PublishData(closeMsg) fmt.Println("专家关é—连接", client.User) } - pool.DelClient(client.Id, client.User) + pool.DelClient(client.User) fmt.Printf("连接己ç»å…³é—%s", client.Id) }) -- 2.18.1