From: qydysky Date: Wed, 17 May 2023 15:06:59 +0000 (+0800) Subject: Fix 组件修复 X-Git-Tag: v0.9.5~6 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=200251401791bad268c5c7b963dd6b7e55bd9dcb;p=bili_danmu%2F.git Fix 组件修复 --- diff --git a/CV/Var.go b/CV/Var.go index 6e1ff75..aa2956b 100644 --- a/CV/Var.go +++ b/CV/Var.go @@ -229,7 +229,7 @@ func (t *Common) Init() *Common { 80: "流畅", } - t.Danmu_Main_mq = mq.New() + t.Danmu_Main_mq = mq.NewTo(time.Second*5, time.Second*10) go func() { //日期变化 var old = time.Now().Hour() diff --git a/bili_danmu.go b/bili_danmu.go index c903300..6627981 100644 --- a/bili_danmu.go +++ b/bili_danmu.go @@ -43,16 +43,24 @@ func Start() { var stop = sys.Sys().PreventSleep() defer stop.Done() + var interrupt_chan = c.C.Danmu_Main_mq.Pull_tag_chan(`interrupt`, 2, context.Background()) + //ctrl+c退出 go func() { var interrupt = make(chan os.Signal, 2) //捕获ctrl+c退出 signal.Notify(interrupt, os.Interrupt) - danmulog.L(`I: `, "ctrl+c退出") - <-interrupt - c.C.Danmu_Main_mq.PushLock_tag(`interrupt`, nil) - danmulog.L(`I: `, "退出!").Block(1000) - os.Exit(1) + danmulog.L(`I: `, "3s内2次ctrl+c退出") + for { + <-interrupt + c.C.Danmu_Main_mq.Push_tag(`interrupt`, nil) + select { + case <-interrupt: + c.C.Danmu_Main_mq.Push_tag(`interrupt`, nil) + os.Exit(1) + case <-time.After(time.Second * 3): + } + } }() // 启动时显示ip @@ -81,7 +89,6 @@ func Start() { reply.SaveToJson.Init() var change_room_chan = c.C.Danmu_Main_mq.Pull_tag_chan(`change_room`, 1, context.Background()) - var interrupt_chan = c.C.Danmu_Main_mq.Pull_tag_chan(`interrupt`, 1, context.Background()) // 房间初始化 if c.C.Roomid != 0 { @@ -172,7 +179,8 @@ func Start() { //对每个弹幕服务器尝试 F.Get(c.C).Get(`WSURL`) - for i, aliveT, exitloop := 0, time.Now().Add(3*time.Hour), false; !exitloop && i < len(c.C.WSURL) && time.Now().Before(aliveT); { + aliveT := time.Now().Add(3 * time.Hour) + for i, exitloop := 0, false; !exitloop && i < len(c.C.WSURL) && time.Now().Before(aliveT); { v := c.C.WSURL[i] //ws启动 danmulog.L(`T: `, "连接 "+v) @@ -234,16 +242,26 @@ func Start() { danmulog.L(`I: `, "已连接到房间", c.C.Uname, `(`, c.C.Roomid, `)`) reply.Gui_show(`进入直播间: `+c.C.Uname+` (`+strconv.Itoa(c.C.Roomid)+`)`, `0room`) if c.C.Title != `` { - danmulog.L(`I: `, c.C.Title) + danmulog.L(`I: `, `房间标题: `+c.C.Title) reply.Gui_show(`房间标题: `+c.C.Title, `0room`) } + wsmsg.Pull_tag(map[string]func(*ws.WsMsg) (disable bool){ + `rec`: func(wm *ws.WsMsg) (disable bool) { + go reply.Reply(wm.Msg) + return false + }, + `close`: func(_ *ws.WsMsg) (disable bool) { + return true + }, + }) + //30s获取一次人气 go func() { danmulog.L(`T: `, "获取人气") heartbeatmsg, heartinterval := F.Heartbeat() for !ws_c.Isclose() { - wsmsg.PushLock_tag(`send`, &ws.WsMsg{ + wsmsg.Push_tag(`send`, &ws.WsMsg{ Msg: heartbeatmsg, }) time.Sleep(time.Millisecond * time.Duration(heartinterval*1000)) @@ -335,15 +353,6 @@ func Start() { }, }) - wsmsg.Pull_tag(map[string]func(*ws.WsMsg) (disable bool){ - `rec`: func(wm *ws.WsMsg) (disable bool) { - go reply.Reply(wm.Msg) - return false - }, - `close`: func(_ *ws.WsMsg) (disable bool) { - return true - }, - }) <-wsmsg.Pull_tag_chan(`exit`, 1, context.Background()) time.Sleep(time.Second) } diff --git a/go.mod b/go.mod index e7ff4d4..4e021a8 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/gotk3/gotk3 v0.6.2 github.com/mdp/qrterminal/v3 v3.0.0 - github.com/qydysky/part v0.27.5 + github.com/qydysky/part v0.27.7 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 golang.org/x/text v0.9.0 diff --git a/go.sum b/go.sum index 1f22e77..177faf4 100644 --- a/go.sum +++ b/go.sum @@ -31,8 +31,8 @@ github.com/mdp/qrterminal/v3 v3.0.0/go.mod h1:NJpfAs7OAm77Dy8EkWrtE4aq+cE6McoLXl github.com/miekg/dns v1.1.54 h1:5jon9mWcb0sFJGpnI99tOMhCPyJ+RPVz5b63MQG0VWI= github.com/miekg/dns v1.1.54/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/qydysky/part v0.27.5 h1:kYiY+zPJ3Odt++th3DiAc0KWBNclwnB1KkDd8hO4xtY= -github.com/qydysky/part v0.27.5/go.mod h1:IEMpGB0NBl6MklZmoenSpS5ChhaIL79JYFo6mF1UkAU= +github.com/qydysky/part v0.27.7 h1:E/Kq9ED5YQid2qLAYxBZoPObyj5TkheDhXTgVn8tTAg= +github.com/qydysky/part v0.27.7/go.mod h1:IEMpGB0NBl6MklZmoenSpS5ChhaIL79JYFo6mF1UkAU= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=