From 949a66917a81d2c3b34f367f747244df01b70634 Mon Sep 17 00:00:00 2001 From: aynakeya Date: Fri, 26 Apr 2024 21:10:17 -0700 Subject: [PATCH] able to start again after stop --- client/client.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/client.go b/client/client.go index 9500cd4..e752f9c 100644 --- a/client/client.go +++ b/client/client.go @@ -69,6 +69,13 @@ func (c *Client) SetCookie(cookie string) { // init 初始化 获取真实 RoomID 和 弹幕服务器 host func (c *Client) init() error { + // reset loop + if c.cancel != nil { + c.cancel() + ctx, cancel := context.WithCancel(context.Background()) + c.cancel = cancel + c.done = ctx.Done() + } if c.api == nil { c.api = api.NewDefaultClient(c.Cookie) }