Start work on improving recordings.

This commit is contained in:
Storm Dragon
2026-05-23 23:33:30 -04:00
parent 08b484f106
commit 3e06de7501
8 changed files with 662 additions and 105 deletions
+36 -10
View File
@@ -174,7 +174,17 @@ func (g *Hall) Description() *Description {
func (g *Hall) ClientCount() int {
g.mu.Lock()
defer g.mu.Unlock()
return len(g.clients)
return g.clientCountUnlocked()
}
func (g *Hall) clientCountUnlocked() int {
count := 0
for _, c := range g.clients {
if !isSystemClient(c) {
count++
}
}
return count
}
func (g *Hall) mayExpire() bool {
@@ -525,6 +535,10 @@ func member(v string, l []string) bool {
return false
}
func isSystemClient(c Client) bool {
return member("system", c.Permissions())
}
func AddClient(hall string, c Client, creds ClientCredentials) (*Hall, error) {
g, err := Add(hall, nil)
if err != nil {
@@ -535,8 +549,9 @@ func AddClient(hall string, c Client, creds ClientCredentials) (*Hall, error) {
defer g.mu.Unlock()
clients := g.getClientsUnlocked(nil)
systemClient := isSystemClient(c)
if !member("system", c.Permissions()) {
if !systemClient {
username, perms, err := g.getPermission(creds)
if err != nil {
return nil, err
@@ -587,7 +602,7 @@ func AddClient(hall string, c Client, creds ClientCredentials) (*Hall, error) {
}
if !member("op", perms) && g.description.MaxClients > 0 {
if len(g.clients) >= g.description.MaxClients {
if g.clientCountUnlocked() >= g.description.MaxClients {
return nil, UserError("too many users")
}
}
@@ -607,12 +622,20 @@ func AddClient(hall string, c Client, creds ClientCredentials) (*Hall, error) {
u := c.Username()
p := c.Permissions()
s := c.Data()
c.PushClient(g.Name(), "add", c.Id(), u, p, s)
if !systemClient {
c.PushClient(g.Name(), "add", c.Id(), u, p, s)
}
for _, cc := range clients {
pp := cc.Permissions()
uu := cc.Username()
c.PushClient(g.Name(), "add", cc.Id(), uu, pp, cc.Data())
cc.PushClient(g.Name(), "add", id, u, p, s)
if !isSystemClient(cc) {
c.PushClient(
g.Name(), "add", cc.Id(), uu, pp, cc.Data(),
)
}
if !systemClient {
cc.PushClient(g.Name(), "add", id, u, p, s)
}
}
return g, nil
@@ -659,6 +682,7 @@ func DelClient(c Client) {
if g == nil {
return
}
systemClient := isSystemClient(c)
g.mu.Lock()
if g.clients[c.Id()] != c {
log.Printf("Deleting unknown client")
@@ -671,10 +695,12 @@ func DelClient(c Client) {
g.mu.Unlock()
c.Joined(g.Name(), "leave")
for _, cc := range clients {
cc.PushClient(
g.Name(), "delete", c.Id(), c.Username(), nil, nil,
)
if !systemClient {
for _, cc := range clients {
cc.PushClient(
g.Name(), "delete", c.Id(), c.Username(), nil, nil,
)
}
}
closeSystemClientsIfNoUsers(g, clients)
autoLockKick(g)