From 6bb73cf30b474f255faceb7a66ec8d2eba059bf8 Mon Sep 17 00:00:00 2001 From: cookeem Date: Wed, 15 Feb 2023 10:57:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=81=87=E5=A6=82=E6=8E=A5=E6=94=B6=E7=9A=84?= =?UTF-8?q?=E4=B8=8D=E6=98=AFtext=E6=B6=88=E6=81=AF=EF=BC=8C=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chat/service.go | 12 +++++++++++- config.yaml | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/chat/service.go b/chat/service.go index 42d3679..1bc576c 100644 --- a/chat/service.go +++ b/chat/service.go @@ -331,7 +331,17 @@ func (api *Api) WsChat(c *gin.Context) { case websocket.PingMessage: api.Logger.LogInfo("[PING] websocket receive ping message") default: - api.Logger.LogError("websocket receive message type error") + err = fmt.Errorf("websocket receive message type not text") + chatMsg := Message{ + Kind: "error", + Msg: err.Error(), + MsgId: uuid.New().String(), + CreateTime: time.Now().Format("2006-01-02 15:04:05"), + } + mutex.Lock() + _ = conn.WriteJSON(chatMsg) + mutex.Unlock() + api.Logger.LogError("websocket receive message type not text") return } } diff --git a/config.yaml b/config.yaml index ff62588..baea4d8 100644 --- a/config.yaml +++ b/config.yaml @@ -9,5 +9,5 @@ maxLength: 2000 # 是否允许cors跨域 cors: true # 问题反馈的超时时间,单位:秒 -timeoutSeconds: 180 +timeoutSeconds: 300