add UserCount() helper (along with previous UserExists() helper)

This commit is contained in:
mappu 2016-05-08 12:37:05 +12:00
parent cc15a571a8
commit 861090b0e9

View File

@ -56,6 +56,13 @@ func (this *HubConnection) UserExists(nick string) bool {
return already_existed 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) { func (this *HubConnection) userJoined_NameOnly(nick string) {
if !this.UserExists(nick) { if !this.UserExists(nick) {
this.userLock.Lock() this.userLock.Lock()