From: qydysky Date: Sun, 21 Jul 2024 00:38:03 +0000 (+0800) Subject: 2 X-Git-Tag: v0.28.20240721004428 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=825724d5307c1ea065907cdc4993097bb22e8551;p=part%2F.git 2 --- diff --git a/websocket/Recoder.go b/websocket/Recoder.go index 241e0dc..7d7b018 100644 --- a/websocket/Recoder.go +++ b/websocket/Recoder.go @@ -100,9 +100,10 @@ func Play(filePath string) (s *Server, close func()) { defer timer.Stop() var ( - cu atomic.Int64 - data []byte - e error + cu atomic.Int64 + data []byte + sendData = pslice.New[byte]() + e error ) s.Interface().Pull_tag(map[string]func(any) (disable bool){ @@ -116,10 +117,6 @@ func Play(filePath string) (s *Server, close func()) { default: if d, err := strconv.ParseFloat(data, 64); err == nil && d > 0 { cu.Store(int64(d)) - s.Interface().Push_tag(`send`, Uinterface{ - Id: 0, //send to all - Data: []byte("ok"), - }) } } } @@ -127,8 +124,6 @@ func Play(filePath string) (s *Server, close func()) { }, }) - sendData := pslice.New[byte]() - for !ctx.Done(sg) { select { case <-timer.C: @@ -141,13 +136,11 @@ func Play(filePath string) (s *Server, close func()) { sendData.Reset() sendData.Append([]byte("[")) for !ctx.Done(sg) { - if data == nil { - if data, e = f.ReadUntil([]byte{'\n'}, 70, humanize.MByte); e != nil && !errors.Is(e, io.EOF) { - panic(e) - } - if len(data) == 0 { - return - } + if data, e = f.ReadUntil([]byte{'\n'}, 70, humanize.MByte); e != nil && !errors.Is(e, io.EOF) { + panic(e) + } + if len(data) == 0 { + return } tIndex := bytes.Index(data, []byte{','})