diff --git a/HubConnection.go b/HubConnection.go index e6c82f8..2943861 100644 --- a/HubConnection.go +++ b/HubConnection.go @@ -74,11 +74,15 @@ func (this *HubConnection) userJoined_NameOnly(nick string) { } func (this *HubConnection) userJoined_Full(uinf *UserInfo) { - if !this.UserExists(uinf.Nick) { - this.userLock.Lock() - defer this.userLock.Unlock() + // n.b. also called when we get a replacement MyINFO for someone + this.userLock.Lock() + defer this.userLock.Unlock() - this.users[uinf.Nick] = *uinf + _, userExisted := this.users[uinf.Nick] // don't use UserExists as it would deadlock the mutex + + this.users[uinf.Nick] = *uinf + + if !userExisted { this.processEvent(HubEvent{EventType: EVENT_USER_JOINED, Nick: uinf.Nick}) } }