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
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 {
//对每个弹幕服务器尝试
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)
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))
},
})
- 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)
}
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=