Commit 48c7ec6d authored by haoyanbin's avatar haoyanbin

Record

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