Commit 48c7ec6d authored by haoyanbin's avatar haoyanbin

Record

parent 2885a2b0
...@@ -376,13 +376,13 @@ func SaveMsg(msg *SendMsg) { ...@@ -376,13 +376,13 @@ func SaveMsg(msg *SendMsg) {
mqData.Participant = msg.FromClientId mqData.Participant = msg.FromClientId
//连接开启信息存入 //连接开启信息存入
conversation := &Conversation{} //conversation := &Conversation{}
conversation.ConversationId = msg.ConversationId //conversation.ConversationId = msg.ConversationId
conversation.Promoter = msg.FromClientId //conversation.Promoter = msg.FromClientId
conversation.Participant = msg.ToClientId //conversation.Participant = msg.ToClientId
conversation.Status = 3 //conversation.Status = 3
conversation.StartReceiveDate = mqData.StartReceiveDate //conversation.StartReceiveDate = mqData.StartReceiveDate
AppendConversation(conversation) //AppendConversation(conversation)
} }
//结束 //结束
...@@ -415,12 +415,13 @@ func SaveMsg(msg *SendMsg) { ...@@ -415,12 +415,13 @@ func SaveMsg(msg *SendMsg) {
mqData.Content = msg.Msg mqData.Content = msg.Msg
mqData.Sender = msg.FromClientId mqData.Sender = msg.FromClientId
mqData.Receiver = msg.ToClientId mqData.Receiver = msg.ToClientId
AppendConversationRecord(msg)
} }
if msg.ProcedureType == 8 { if msg.ProcedureType == 8 {
mqData.Finish = "5" mqData.Finish = "5"
mqData.EndTime = msg.SendTime mqData.EndTime = msg.SendTime
DelConversation(msg.ConversationId) //DelConversation(msg.ConversationId)
} }
if mqData.ProcedureType != 0 { if mqData.ProcedureType != 0 {
...@@ -459,23 +460,17 @@ func GetAllList(key string) map[string]string { ...@@ -459,23 +460,17 @@ func GetAllList(key string) map[string]string {
return jsonDataAll return jsonDataAll
} }
func AppendConversation(conversation *Conversation) { func AppendConversationRecord(msg *SendMsg) {
Redis.HSetNX(convKey, strconv.Itoa(conversation.ConversationId), string(SerializeJson(conversation))) Redis.HSetNX("msg:"+strconv.Itoa(msg.ConversationId), msg.FromClientId+":"+msg.ToClientId, string(SerializeJson(msg)))
return return
} }
func DelConversationRecord(conversationId int) { func GetConversationRecord(conversationId int) {
Redis.HDel(convKey, strconv.Itoa(conversationId)) //Redis.HGet()
return
}
func AppendConversationRecord(conversation *SendMsg) {
Redis.HSetNX(convKey+":"+strconv.Itoa(conversation.ConversationId), strconv.Itoa(conversation.ConversationId), string(SerializeJson(conversation)))
return
} }
func DelConversation(conversationId int) { func DelConversation(conversationId int) {
Redis.HDel(convKey, strconv.Itoa(conversationId)) Redis.HDel("msg:" + strconv.Itoa(conversationId))
return return
} }
......
...@@ -61,6 +61,8 @@ func main() { ...@@ -61,6 +61,8 @@ func main() {
mux.HandleFunc("/ws", ws) mux.HandleFunc("/ws", ws)
mux.HandleFunc("/ws-list", GetClientList) mux.HandleFunc("/ws-list", GetClientList)
mux.HandleFunc("/ws-conv-list", GetConversationList)
mux.HandleFunc("/ws-record-list", GetConversationRecordList)
err := http.ListenAndServe(":11001", mux) err := http.ListenAndServe(":11001", mux)
if err != nil { if err != nil {
fmt.Printf("ListenAndServe: %s", err.Error()) fmt.Printf("ListenAndServe: %s", err.Error())
...@@ -179,6 +181,22 @@ func GetClientList(w http.ResponseWriter, r *http.Request) { ...@@ -179,6 +181,22 @@ func GetClientList(w http.ResponseWriter, r *http.Request) {
resp(w, reply) resp(w, reply)
} }
func GetConversationList(w http.ResponseWriter, r *http.Request) {
//data := r.URL.Query()
reply := pool.GetAllList("msg:*")
resp(w, reply)
}
func GetConversationRecordList(w http.ResponseWriter, r *http.Request) {
data := r.URL.Query()
reply := pool.GetAllList("msg:" + data["conversationId"][0])
resp(w, reply)
}
func resp(w http.ResponseWriter, data interface{}) { func resp(w http.ResponseWriter, data interface{}) {
w.Header().Set("content-type", "text/json") w.Header().Set("content-type", "text/json")
w.WriteHeader(200) w.WriteHeader(200)
......
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