diff --git a/controller/chat.go b/controller/chat.go index b468c97..7f0de86 100644 --- a/controller/chat.go +++ b/controller/chat.go @@ -53,7 +53,7 @@ func init() { ReadBufferSize: 1024, WriteBufferSize: 1024, } - go UpdateVisitorStatusCron() + //go UpdateVisitorStatusCron() go singleBroadcaster() //go sendPingOnlineUsers() //sendPingToClient() diff --git a/controller/message.go b/controller/message.go index 445b01d..fea27db 100644 --- a/controller/message.go +++ b/controller/message.go @@ -159,31 +159,32 @@ func SendMessageV2(c *gin.Context) { msg = TypeMessage{ Type: "message", - Data: ClientMessage{ + Data: ws.ClientMessage{ Name: kefuInfo.Nickname, Avator: kefuInfo.Avator, Id: kefuInfo.Name, Time: time.Now().Format("2006-01-02 15:04:05"), ToId: vistorInfo.VisitorId, Content: content, + IsKefu: "no", }, } str, _ := json.Marshal(msg) conn.WriteMessage(websocket.TextMessage, str) - //msg = TypeMessage{ - // Type: "message", - // Data: ClientMessage{ - // Name: kefuInfo.Nickname, - // Avator: kefuInfo.Avator, - // Id: vistorInfo.VisitorId, - // Time: time.Now().Format("2006-01-02 15:04:05"), - // ToId: vistorInfo.VisitorId, - // Content: content, - // }, - //} - //str2, _ := json.Marshal(msg) - //ws.SuperAdminMessage(str2) - + msg = TypeMessage{ + Type: "message", + Data: ws.ClientMessage{ + Name: kefuInfo.Nickname, + Avator: kefuInfo.Avator, + Id: vistorInfo.VisitorId, + Time: time.Now().Format("2006-01-02 15:04:05"), + ToId: vistorInfo.VisitorId, + Content: content, + IsKefu: "yes", + }, + } + str2, _ := json.Marshal(msg) + ws.OneKefuMessage(kefuInfo.Name, str2) } if cType == "visitor" { //kefuConns, ok := ws.KefuList[kefuInfo.Name] @@ -196,13 +197,14 @@ func SendMessageV2(c *gin.Context) { //} msg = TypeMessage{ Type: "message", - Data: ClientMessage{ + Data: ws.ClientMessage{ Avator: vistorInfo.Avator, Id: vistorInfo.VisitorId, Name: vistorInfo.Name, ToId: kefuInfo.Name, Content: content, Time: time.Now().Format("2006-01-02 15:04:05"), + IsKefu: "no", }, } str, _ := json.Marshal(msg) diff --git a/static/js/chat-main.js b/static/js/chat-main.js index 3cc0a3f..24491c3 100644 --- a/static/js/chat-main.js +++ b/static/js/chat-main.js @@ -129,11 +129,21 @@ var app=new Vue({ content.avator = msg.avator; content.name = msg.name; content.content = replaceContent(msg.content); - content.is_kefu = false; + content.is_kefu = msg.is_kefu=="yes"? true:false; content.time = msg.time; if (msg.id == this.currentGuest) { this.msgList.push(content); } + + for(let i=0;i