From f68a711c79a476b8de349efd0625dce2c0418ea1 Mon Sep 17 00:00:00 2001 From: chenqinghe Date: Fri, 14 Oct 2022 13:42:35 +0800 Subject: [PATCH] feat: fix nil user --- manager.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/manager.go b/manager.go index ffb53bf..1a7b397 100644 --- a/manager.go +++ b/manager.go @@ -109,9 +109,11 @@ func (m *Manager) StoreConn(c Conn) (*Session, error) { m.conns[sess.Id()] = sess m.mu.Unlock() - m.ulock.Lock() - m.users[sess.User().Id()] = sess - m.ulock.Unlock() + if user != nil { + m.ulock.Lock() + m.users[user.Id()] = sess + m.ulock.Unlock() + } logrus.Debug("accept a new connection, remote addr:" + c.RemoteAddr().String())