结构修改

This commit is contained in:
renzhiyuan 2025-09-29 16:58:06 +08:00
parent 7a1662943e
commit 7cc7555bbe
2 changed files with 7 additions and 0 deletions

View File

@ -214,6 +214,11 @@ func sendWithTimeout(c *websocket.Conn, data entitys.Response, timeout time.Dura
done := make(chan error, 1)
go func() {
defer func() {
if r := recover(); r != nil {
done <- fmt.Errorf("panic in MsgSend: %v", r)
}
}()
done <- entitys.MsgSend(c, data)
}()

View File

@ -47,6 +47,8 @@ func MsgSet(msgType ResponseType, msg string, done bool) []byte {
}
func MsgSend(c *websocket.Conn, msg Response) error {
// 检查上下文是否已取消
jsonByte, _ := json.Marshal(msg)
return c.WriteMessage(websocket.TextMessage, jsonByte)