Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

客户端websocket退出房间后,有时候服务端会崩溃 #2

Open
saner-qu opened this issue Aug 4, 2022 · 3 comments
Open

Comments

@saner-qu
Copy link

saner-qu commented Aug 4, 2022

崩溃的地方在main.go User.OnEvent,原因是data.(*common.DataFrame[any]).Value为nil
原代码:
func (u *User) OnEvent(event any) { switch v := event.(type) { case *track.Data: u.AddTrack(v) go v.Play(u.IO, func(data any) error { u.writeLock.Lock() defer u.writeLock.Unlock() return wsutil.WriteServerText(u.Conn, data.(*common.DataFrame[any]).Value.([]byte)) }) default: u.Subscriber.OnEvent(event) } }
修改代码:
在defer u.writeLock.Unlock()下面增加:
if data.(*common.DataFrame[any]).Value == nil { return nil }

@langhuihui
Copy link
Member

嗯,在Play里面缺少了判断ring被销毁的条件了

1 similar comment
@langhuihui
Copy link
Member

嗯,在Play里面缺少了判断ring被销毁的条件了

@qq912150317
Copy link

@saner-qu 求问您客户端用的什么?自己开发的吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants