mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Implement NewDiskClient.
This commit is contained in:
parent
7126394e65
commit
f2fcc09e61
2 changed files with 20 additions and 4 deletions
19
disk.go
19
disk.go
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -24,6 +25,24 @@ type diskClient struct {
|
|||
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 {
|
||||
return client.group
|
||||
}
|
||||
|
|
|
@ -1078,10 +1078,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
|||
return c.error(userError("already recording"))
|
||||
}
|
||||
}
|
||||
disk := &diskClient{
|
||||
group: c.group,
|
||||
id: "recording",
|
||||
}
|
||||
disk := NewDiskClient(c.group)
|
||||
_, err := addClient(c.group.name, disk)
|
||||
if err != nil {
|
||||
disk.Close()
|
||||
|
|
Loading…
Reference in a new issue