Commit f2fcc09e authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement NewDiskClient.

parent 7126394e
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"strconv"
"sync" "sync"
"time" "time"
...@@ -24,6 +25,24 @@ type diskClient struct { ...@@ -24,6 +25,24 @@ type diskClient struct {
closed bool closed bool
} }
var idCounter struct {
mu sync.Mutex
counter int
}
func newId() string {
idCounter.mu.Lock()
defer idCounter.mu.Unlock()
s := strconv.FormatInt(int64(idCounter.counter), 16)
idCounter.counter++
return s
}
func NewDiskClient(g *group) *diskClient {
return &diskClient{group: g, id: newId()}
}
func (client *diskClient) Group() *group { func (client *diskClient) Group() *group {
return client.group return client.group
} }
......
...@@ -1078,10 +1078,7 @@ func handleClientMessage(c *webClient, m clientMessage) error { ...@@ -1078,10 +1078,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
return c.error(userError("already recording")) return c.error(userError("already recording"))
} }
} }
disk := &diskClient{ disk := NewDiskClient(c.group)
group: c.group,
id: "recording",
}
_, err := addClient(c.group.name, disk) _, err := addClient(c.group.name, disk)
if err != nil { if err != nil {
disk.Close() disk.Close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment