From c34f6a040b7ec1e173601d453b0492ae330e1ab7 Mon Sep 17 00:00:00 2001 From: qydysky <32743305+qydysky@users.noreply.github.com> Date: Thu, 16 Feb 2023 21:27:27 +0800 Subject: [PATCH] fix --- websocket/Recoder.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/websocket/Recoder.go b/websocket/Recoder.go index dc7f497..9b66d95 100644 --- a/websocket/Recoder.go +++ b/websocket/Recoder.go @@ -105,7 +105,7 @@ func Play(filePath string) (s *Server, close func()) { s.Interface().Pull_tag(map[string]func(any) (disable bool){ `recv`: func(a any) (disable bool) { if d, ok := a.(Uinterface); ok { - switch string(d.Data) { + switch data := string(d.Data); data { case "pause": timer.Stop() case "play": @@ -122,7 +122,7 @@ func Play(filePath string) (s *Server, close func()) { for sg.Islive() { if data == nil { - if data, e = f.ReadUntil('\n', humanize.KByte, humanize.MByte); e != nil && !errors.Is(e, io.EOF) { + if data, e = f.ReadUntil('\n', 70, humanize.MByte); e != nil && !errors.Is(e, io.EOF) { panic(e) } if len(data) == 0 { @@ -131,17 +131,16 @@ func Play(filePath string) (s *Server, close func()) { } tIndex := bytes.Index(data, []byte{','}) - if d, _ := strconv.ParseFloat(string(data[:tIndex]), 64); d > cu { - break + if d, _ := strconv.ParseFloat(string(data[:tIndex]), 64); d < cu { + danmuIndex := tIndex + bytes.Index(data[tIndex+2:], []byte{','}) + 3 + s.Interface().Push_tag(`send`, Uinterface{ + Id: 0, //send to all + Data: data[danmuIndex:], + }) + data = nil } - danmuIndex := tIndex + bytes.Index(data[tIndex+2:], []byte{','}) + 3 - s.Interface().Push_tag(`send`, Uinterface{ - Id: 0, //send to all - Data: data[danmuIndex:], - }) - - data = nil + break } } -- 2.39.2