Commit d1c68f90 authored by haoyanbin's avatar haoyanbin

Redis

parent 82343b50
...@@ -143,7 +143,7 @@ func (c *Client) readPump() { ...@@ -143,7 +143,7 @@ func (c *Client) readPump() {
close(c.sendPing) close(c.sendPing)
c.grpool.Close() c.grpool.Close()
c.hub.RemoveClient(c) c.hub.RemoveClient(c)
DelClient(c.Id,c.User) DelClient(c.User)
dump() dump()
}() }()
Loop: Loop:
......
...@@ -69,7 +69,8 @@ func NewClient(conf *Config) *Client { ...@@ -69,7 +69,8 @@ func NewClient(conf *Config) *Client {
client.OnPing(nil) client.OnPing(nil)
client.OnPong(nil) client.OnPong(nil)
wsSever.hub.AddClient(client) 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 return client
} }
...@@ -507,13 +508,13 @@ func DelConversation(conversationId int) { ...@@ -507,13 +508,13 @@ func DelConversation(conversationId int) {
return return
} }
func AppendClient(clientId, clientUser, data string) { func AppendClient(client, data string) {
Redis.HSet(cliKey+":"+clientId, clientUser, data) Redis.HSet(cliKey, client, data)
return return
} }
func DelClient(clientId, clientUser string) { func DelClient(client string) {
Redis.HDel(cliKey+":"+clientId, clientUser) Redis.HDel(cliKey, client)
return return
} }
......
...@@ -154,7 +154,7 @@ func ws(w http.ResponseWriter, r *http.Request) { ...@@ -154,7 +154,7 @@ func ws(w http.ResponseWriter, r *http.Request) {
pool.PublishData(closeMsg) pool.PublishData(closeMsg)
fmt.Println("专家关闭连接", client.User) fmt.Println("专家关闭连接", client.User)
} }
pool.DelClient(client.Id, client.User) pool.DelClient(client.User)
fmt.Printf("连接己经关闭%s", client.Id) fmt.Printf("连接己经关闭%s", client.Id)
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment