假如接收的不是text消息,返回错误提示

This commit is contained in:
cookeem
2023-02-15 10:57:03 +08:00
parent 37d888228c
commit 6bb73cf30b
2 changed files with 12 additions and 2 deletions

View File

@@ -331,7 +331,17 @@ func (api *Api) WsChat(c *gin.Context) {
case websocket.PingMessage: case websocket.PingMessage:
api.Logger.LogInfo("[PING] websocket receive ping message") api.Logger.LogInfo("[PING] websocket receive ping message")
default: 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 return
} }
} }

View File

@@ -9,5 +9,5 @@ maxLength: 2000
# 是否允许cors跨域 # 是否允许cors跨域
cors: true cors: true
# 问题反馈的超时时间,单位:秒 # 问题反馈的超时时间,单位:秒
timeoutSeconds: 180 timeoutSeconds: 300