mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-11 06:29:29 +01:00
commit
1c110fa501
@ -28,14 +28,6 @@ func (clients *ClientManager) Initialize() {
|
|||||||
clients.bySkeleton = make(map[string]*Client)
|
clients.bySkeleton = make(map[string]*Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count returns how many clients are in the manager.
|
|
||||||
func (clients *ClientManager) Count() int {
|
|
||||||
clients.RLock()
|
|
||||||
defer clients.RUnlock()
|
|
||||||
count := len(clients.byNick)
|
|
||||||
return count
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get retrieves a client from the manager, if they exist.
|
// Get retrieves a client from the manager, if they exist.
|
||||||
func (clients *ClientManager) Get(nick string) *Client {
|
func (clients *ClientManager) Get(nick string) *Client {
|
||||||
casefoldedName, err := CasefoldName(nick)
|
casefoldedName, err := CasefoldName(nick)
|
||||||
@ -262,21 +254,6 @@ func (clients *ClientManager) AllClients() (result []*Client) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// AllWithCaps returns all clients with the given capabilities.
|
|
||||||
func (clients *ClientManager) AllWithCaps(capabs ...caps.Capability) (sessions []*Session) {
|
|
||||||
clients.RLock()
|
|
||||||
defer clients.RUnlock()
|
|
||||||
for _, client := range clients.byNick {
|
|
||||||
for _, session := range client.Sessions() {
|
|
||||||
if session.capabilities.HasAll(capabs...) {
|
|
||||||
sessions = append(sessions, session)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// AllWithCapsNotify returns all clients with the given capabilities, and that support cap-notify.
|
// AllWithCapsNotify returns all clients with the given capabilities, and that support cap-notify.
|
||||||
func (clients *ClientManager) AllWithCapsNotify(capabs ...caps.Capability) (sessions []*Session) {
|
func (clients *ClientManager) AllWithCapsNotify(capabs ...caps.Capability) (sessions []*Session) {
|
||||||
capabs = append(capabs, caps.CapNotify)
|
capabs = append(capabs, caps.CapNotify)
|
||||||
|
Loading…
Reference in New Issue
Block a user