Added ListSubscriber, Unpublish and Retrieve commands

This commit is contained in:
Amalvy Arthur 2018-12-31 02:46:05 +01:00
parent ef2866e89b
commit ff91955361
2 changed files with 109 additions and 18 deletions

View file

@ -61,6 +61,17 @@ func (u users) Set(username string, key, data string) {
go uf.write()
}
// Get all known usernames
func (u users) GetUsernames() []string {
u.mutex.Lock()
defer u.mutex.Unlock()
var usernames []string
for username, _ := range u.data {
usernames = append(usernames, username)
}
return usernames
}
func (u usersFile) read() {
u.mutex.Lock()
defer u.mutex.Unlock()