From 414c1d98ee4d6f0bab50458a3c97e6f828afbc0d Mon Sep 17 00:00:00 2001 From: claudemiro Date: Thu, 15 Jan 2015 07:52:23 -0300 Subject: [PATCH] Calculating the total of users in a channel --- conn.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/conn.go b/conn.go index a67ea0b..9480c42 100644 --- a/conn.go +++ b/conn.go @@ -73,9 +73,14 @@ func (c *Channel) TotalSubscriptions() int { } // Get the total of users. -// For now, totalUsers is equal to totalSubscribers func (c *Channel) TotalUsers() int { - return c.TotalSubscriptions() + total := make(map[string]int) + + for _, s := range c.Subscriptions { + total[s.Id]++ + } + + return len(total) } // Add a new subscriber to the channel