From: qydysky <32743305+qydysky@users.noreply.github.com> Date: Sat, 15 Oct 2022 21:09:23 +0000 (+0800) Subject: fix X-Git-Tag: v0.10.6 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=cf6e39fa21d2bf21d93036633ad0bc43b07c71ba;p=part%2F.git fix --- diff --git a/websocket/Recoder.go b/websocket/Recoder.go index ad50c2d..faa287d 100644 --- a/websocket/Recoder.go +++ b/websocket/Recoder.go @@ -92,23 +92,31 @@ func Play(filePath string, perReadSize int, maxReadSize int) (s *Server, close f startT := time.Now() timer := time.NewTicker(time.Second) + var ( + data []byte + err error + ) for sg.Islive() { cu := (<-timer.C).Sub(startT).Seconds() for sg.Islive() { - if data, err := f.ReadUntil('\n', perReadSize, maxReadSize); err != nil { - panic(err) - } else if len(data) != 0 { + if data == nil { + if data, err = f.ReadUntil('\n', perReadSize, maxReadSize); err != nil { + panic(err) + } + } + if len(data) != 0 { tIndex := bytes.Index(data, []byte{','}) + if d, _ := strconv.ParseFloat(string(data[:tIndex]), 64); d > cu { + break + } danmuIndex := tIndex + bytes.Index(data[tIndex+2:], []byte{','}) + 3 s.Interface().Push_tag(`send`, Uinterface{ Id: 0, //send to all Data: data[danmuIndex:], }) - if d, _ := strconv.ParseFloat(string(data[:tIndex]), 64); d > cu { - break - } + data = nil } else { break } diff --git a/websocket/l.csv b/websocket/l.csv index 080dc2b..92d8996 100644 --- a/websocket/l.csv +++ b/websocket/l.csv @@ -1,3 +1,4 @@ -3.325727,824637721992,send get.server:close after 4 s -6.333226,824637721992,send get.server:close after 3 s -9.335760,824637721992,send get.server:close after 2 s +1.898631,0,{"text":"宫本麦狗: 好耶","style":{"color":"#58c1de"}} +42.360965,0,{"text":"-夜未明-: 七点二十要做核酸,干脆不睡了吧","style":{"color":"#54eed8"}} +120.213335,0,{"text":"信长の天下布武: ybb","style":{"color":"#ffffff"}} +122.861375,0,{"text":"qu-qi: hhhhh","style":{"color":"#54eed8"}}