Commit d1c68f90 authored by haoyanbin's avatar haoyanbin

Redis

parent 82343b50
......@@ -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:
......
......@@ -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
}
......
......@@ -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)
})
......
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