假如接收的不是text消息,返回错误提示
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ maxLength: 2000
|
|||||||
# 是否允许cors跨域
|
# 是否允许cors跨域
|
||||||
cors: true
|
cors: true
|
||||||
# 问题反馈的超时时间,单位:秒
|
# 问题反馈的超时时间,单位:秒
|
||||||
timeoutSeconds: 180
|
timeoutSeconds: 300
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user