]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Fix 组件修复
authorqydysky <qydysky@foxmail.com>
Wed, 17 May 2023 15:06:59 +0000 (23:06 +0800)
committerqydysky <qydysky@foxmail.com>
Wed, 17 May 2023 15:07:02 +0000 (23:07 +0800)
CV/Var.go
bili_danmu.go
go.mod
go.sum

index 6e1ff75bb11578fad2cb4e2cc00fe19d457f2e07..aa2956b90b0b832c091be6119fdf9485d4d14ee5 100644 (file)
--- 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()
index c903300a3da9f182f3bfa97b36d01cd6f569854b..6627981a569b5e339e959441af8dab88328f2284 100644 (file)
@@ -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 e7ff4d4a9db843ddf0a5339e1a8f37fd2858ff11..4e021a859f2730d1418d9329bb452f8f4232ab3e 100644 (file)
--- 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 1f22e77354b42b32fb3f798a5da39683aaef9772..177faf473fa5476d8b6e9e2f65f08ed99e258a35 100644 (file)
--- 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=