]> 127.0.0.1 Git - part/.git/commitdiff
fix v0.10.6
authorqydysky <32743305+qydysky@users.noreply.github.com>
Sat, 15 Oct 2022 21:09:23 +0000 (05:09 +0800)
committerqydysky <32743305+qydysky@users.noreply.github.com>
Sat, 15 Oct 2022 21:09:23 +0000 (05:09 +0800)
websocket/Recoder.go
websocket/l.csv

index ad50c2dab2c4d2c447418c6063c5b67bf0db1b0e..faa287debc64c1b9f10553c41aa86dea62d02f46 100644 (file)
@@ -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
                                }
index 080dc2b7efe63ea3eedbe1434bfeb22bf5b7a679..92d89966134681135d4485b567e835f6fd8839bd 100644 (file)
@@ -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"}}