Closed metalmatze closed 7 years ago
Additionally, when looking at the code for hub{}
I think there needs to be a mutex for the map[*Session]bool
and for open
. 😉
Isn't it possible to do what you want by just using HandleConnect
and HandleDisconnect
why do you need to access hub
?
I don't think a mutex is needed because hub
is running in a single go routine.
Yes, I can do that outside of this library like:
type SessionCount struct {
mu sync.RWMutex
Count uint
}
But I rather dislike this approach, because it's already handled in the hub
. Maybe we can add aLen() int
. Also GetSession()
would be nice, but not mandatory for me.
I think a Len()
method would be a great idea. I will add one this week.
Len()
method is now added to Melody
. Thanks @metalmatze .
Hey, I need a way to figure out if a there are active sessions because I only want to do work if there are any. I almost implemented something like the
melody.hub
myself, but I think that it would be better to make this public or provide some kind of API. Thanks