"fmt"
"io"
"strconv"
+ "sync/atomic"
"time"
"github.com/dustin/go-humanize"
defer timer.Stop()
var (
- cu float64
+ cu atomic.Int64
data []byte
e error
)
timer.Stop()
case "play":
timer.Reset(time.Second)
+ 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"),
+ })
+ }
}
}
return false
return
}
- cu += 1
+ cu.Add(1)
for !ctx.Done(sg) {
if data == nil {
}
tIndex := bytes.Index(data, []byte{','})
- if d, _ := strconv.ParseFloat(string(data[:tIndex]), 64); d < cu {
+ if d, _ := strconv.ParseFloat(string(data[:tIndex]), 64); d < float64(cu.Load()) {
danmuIndex := tIndex + bytes.Index(data[tIndex+2:], []byte{','}) + 3
s.Interface().Push_tag(`send`, Uinterface{
Id: 0, //send to all