Commit 0bbe94eb authored by haoyanbin's avatar haoyanbin

1

parent 4d5d4553
......@@ -60,20 +60,20 @@ type RuntimeInfo struct {
}
type SendMsg struct {
MsgId string `json:"msgId"`
SendTime string `json:"sendTime"` //消息发送时间
FromClientId string `json:"fromClientId"` //指令消息的来源。发送者的连接ID
ToClientId string `json:"toClientId"` //指令消息的接收者。发送给对应的客户端连接ID
CmdData []byte `json:"cmdData"` //对应指令的CmdData1的protobuf的message
Status int `json:"status"` //消息发送响应状态
Priority int `json:"priority"` //用于处理指令队列的优先级的权重值
BusinessId string `json:"businessId"` //客户端标识消息的id,主要区分相同cmd的不同消息,方便收到回复分发处理等效果,考虑长度问题定义成string
GroupId string `json:"groupId"` //服务端发送消息的ID,主要区分相同cmd的不同消息,方便服务端收到回复分发处理等效果,考虑长度问题定义成string
Channel []string `json:"channel"` //指定需要广播的频道,可以指定一个或多个频道
ProcedureType int `json:"procedureType"` //会话状态 1 开始导诊 2 等待连接 3 离线 4 双方建立连接 5 结束会话 6 对话 7 已读 8 超时关闭
MsgType int `json:"msgType"` // msg类型 procedureType=6时填写 1 文本消息 2 图片消息
Msg string `json:"msg"` //一般用于json数据传递,或消息发送响应内容
Desc string `json:"desc"` //消息介绍内容,或其它数据
ConversationId int `json:"conversationId"`
SendTime string `json:"sendTime"` //消息发送时间
FromClientId string `json:"fromClientId"` //指令消息的来源。发送者的连接ID
ToClientId string `json:"toClientId"` //指令消息的接收者。发送给对应的客户端连接ID
CmdData []byte `json:"cmdData"` //对应指令的CmdData1的protobuf的message
Status int `json:"status"` //消息发送响应状态
Priority int `json:"priority"` //用于处理指令队列的优先级的权重值
BusinessId string `json:"businessId"` //客户端标识消息的id,主要区分相同cmd的不同消息,方便收到回复分发处理等效果,考虑长度问题定义成string
GroupId string `json:"groupId"` //服务端发送消息的ID,主要区分相同cmd的不同消息,方便服务端收到回复分发处理等效果,考虑长度问题定义成string
Channel []string `json:"channel"` //指定需要广播的频道,可以指定一个或多个频道
ProcedureType int `json:"procedureType"` //会话状态 1 开始导诊 2 等待连接 3 离线 4 双方建立连接 5 结束会话 6 对话 7 已读 8 超时关闭
MsgType int `json:"msgType"` // msg类型 procedureType=6时填写 1 文本消息 2 图片消息
Msg string `json:"msg"` //一般用于json数据传递,或消息发送响应内容
Desc string `json:"desc"` //消息介绍内容,或其它数据
}
// Client is a middleman between the websocket connection and the hub.
......@@ -114,8 +114,9 @@ type Client struct {
//}
type Conversation struct {
CustomerClientId string `json:"customerClientId"`
UserClientId string `json:"userClientId"`
ConversationId int `json:"conversationId"`
Promoter string `json:"promoter"`
Participant string `json:"participant"`
StartTime string `json:"startTime"`
StartReceiveDate string `json:"startReceiveDate"`
Status int `json:"status"`
......
This diff is collapsed.
......@@ -97,12 +97,6 @@ func ws(w http.ResponseWriter, r *http.Request) {
//接收消息
client.OnMessage(func(msg *pool.SendMsg) {
user := pool.GetClientInfoById(client.Id)
if user.Promoter == "1" {
msg.BusinessId = user.Source
} else if user.Promoter == "2" {
msg.GroupId = user.Source
}
if msg.Status == 3 {
fmt.Println("OnMessage:收到出错消息=》", client.Id, msg.Desc)
......@@ -143,24 +137,17 @@ func ws(w http.ResponseWriter, r *http.Request) {
closeMsg := &pool.SetMsgReq{}
closeMsg.ProcedureType = 5
closeMsg.EndTime = time.Now().Format("2006-01-02 15:04:05")
closeMsg.Promoter = user.Promoter
if user.Promoter == "1" {
closeMsg.Finish = "3"
if user.CustomerType == "1" {
closeMsg.Promoter = client.Id
if userInfo.Source != "" {
closeMsg.BusinessId, _ = pool.DataAesDecrypt(userInfo.Source)
}
closeMsg.CustomerId = userInfo.CustomerId
pool.PublishData(closeMsg)
fmt.Println("用户关闭连接", client.Id)
}
if user.Promoter == "2" {
closeMsg.Finish = "4"
closeMsg.GroupId = userInfo.Source
closeMsg.UserId = userInfo.CustomerId
if user.CustomerType == "2" {
closeMsg.Participant = client.Id
pool.PublishData(closeMsg)
fmt.Println("专家关闭连接", client.Id)
}
......@@ -182,17 +169,17 @@ func ws(w http.ResponseWriter, r *http.Request) {
func GetClientList(w http.ResponseWriter, r *http.Request) {
data := r.URL.Query()
list := pool.GetList(data["source"][0], data["promoter"][0])
list := pool.GetList(data["source"][0], data["sourceId"][0], data["customerType"][0])
reply := make([]string, 0)
for k := range list {
reply = append(reply, k)
}
resp(w,reply)
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.WriteHeader(200)
w.Write(pool.SerializeJson(data))
......
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