From 722bcabb9b7f95e199efe202c4d0e1f49546022c Mon Sep 17 00:00:00 2001 From: qydysky <32743305+qydysky@users.noreply.github.com> Date: Sat, 21 Jan 2023 02:57:05 +0800 Subject: [PATCH] =?utf8?q?Improve=20=E5=9B=9E=E6=94=B6ws=E6=B3=A8=E5=86=8C?= =?utf8?q?=E7=9A=84=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- bili_danmu.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bili_danmu.go b/bili_danmu.go index 320ea59..fbfb31c 100644 --- a/bili_danmu.go +++ b/bili_danmu.go @@ -248,16 +248,19 @@ func Start() { F.Get(&c.C).Get(`GuardNum`) // 在线人数 F.Get(&c.C).Get(`getOnlineGoldRank`) - //使用带tag的消息队列在功能间传递消息 + //当前ws的消息队列 c.C.Danmu_Main_mq.Pull_tag(msgq.FuncMap{ + `exit_cu_room`: func(_ any) bool { //退出 + return true + }, `guard_update`: func(_ any) bool { //舰长更新 go F.Get(&c.C).Get(`GuardNum`) return false }, - `flash_room`: func(data any) bool { //重进房时退出当前房间 + `flash_room`: func(_ any) bool { //重进房时退出当前房间 return true }, - `change_room`: func(data any) bool { //换房时退出当前房间 + `change_room`: func(_ any) bool { //换房时退出当前房间 return true }, `every100s`: func(_ any) bool { //每100s @@ -331,6 +334,9 @@ func Start() { } } + // 当前ws链接断开时,取消当前ws的消息队列 + c.C.Danmu_Main_mq.Push_tag(`exit_cu_room`, nil) + if break_sign { break } -- 2.39.2