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
}
-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"}}