From 861090b0e9325af5ef3c340e8d1b3583d9490e9b Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 8 May 2016 12:37:05 +1200 Subject: [PATCH] add UserCount() helper (along with previous UserExists() helper) --- HubConnection.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/HubConnection.go b/HubConnection.go index 3981184..7539908 100644 --- a/HubConnection.go +++ b/HubConnection.go @@ -56,6 +56,13 @@ func (this *HubConnection) UserExists(nick string) bool { return already_existed } +func (this *HubConnection) UserCount() int { + this.userLock.RLock() + defer this.userLock.RUnlock() + + return len(this.users) +} + func (this *HubConnection) userJoined_NameOnly(nick string) { if !this.UserExists(nick) { this.userLock.Lock()