mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Rename pushConns to requestConns, move into Client interface.
Also allow selecting just a single connection.
This commit is contained in:
parent
435f46c520
commit
515c4a5cd0
3 changed files with 23 additions and 13 deletions
|
@ -79,6 +79,10 @@ func (client *Client) PushClient(id, username string, permissions *group.ClientP
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (client *Client) RequestConns(target group.Client, g *group.Group, id string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (client *Client) Close() error {
|
func (client *Client) Close() error {
|
||||||
client.mu.Lock()
|
client.mu.Lock()
|
||||||
defer client.mu.Unlock()
|
defer client.mu.Unlock()
|
||||||
|
|
|
@ -101,6 +101,7 @@ type Client interface {
|
||||||
Status() map[string]interface{}
|
Status() map[string]interface{}
|
||||||
OverridePermissions(*Group) bool
|
OverridePermissions(*Group) bool
|
||||||
PushConn(g *Group, id string, conn conn.Up, tracks []conn.UpTrack, replace string) error
|
PushConn(g *Group, id string, conn conn.Up, tracks []conn.UpTrack, replace string) error
|
||||||
|
RequestConns(target Client, g *Group, id string) error
|
||||||
PushClient(id, username string, permissions *ClientPermissions, status map[string]interface{}, kind string) error
|
PushClient(id, username string, permissions *ClientPermissions, status map[string]interface{}, kind string) error
|
||||||
Kick(id, user, message string) error
|
Kick(id, user, message string) error
|
||||||
}
|
}
|
||||||
|
|
|
@ -644,17 +644,18 @@ func (c *webClient) setRequested(requested map[string][]string) error {
|
||||||
}
|
}
|
||||||
c.requested = requested
|
c.requested = requested
|
||||||
|
|
||||||
pushConns(c, c.group)
|
requestConns(c, c.group, "")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func pushConns(c group.Client, g *group.Group) {
|
func (c *webClient) RequestConns(target group.Client, g *group.Group, id string) error {
|
||||||
clients := g.GetClients(c)
|
return c.action(requestConnsAction{g, target, id})
|
||||||
for _, cc := range clients {
|
|
||||||
ccc, ok := cc.(*webClient)
|
|
||||||
if ok {
|
|
||||||
ccc.action(pushConnsAction{g, c})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func requestConns(target group.Client, g *group.Group, id string) {
|
||||||
|
clients := g.GetClients(target)
|
||||||
|
for _, c := range clients {
|
||||||
|
c.RequestConns(target, g, id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,9 +802,10 @@ type pushConnAction struct {
|
||||||
replace string
|
replace string
|
||||||
}
|
}
|
||||||
|
|
||||||
type pushConnsAction struct {
|
type requestConnsAction struct {
|
||||||
group *group.Group
|
group *group.Group
|
||||||
client group.Client
|
target group.Client
|
||||||
|
id string
|
||||||
}
|
}
|
||||||
|
|
||||||
type connectionFailedAction struct {
|
type connectionFailedAction struct {
|
||||||
|
@ -933,12 +935,15 @@ func handleAction(c *webClient, a interface{}) error {
|
||||||
closeDownConn(c, down.id,
|
closeDownConn(c, down.id,
|
||||||
"negotiation failed")
|
"negotiation failed")
|
||||||
}
|
}
|
||||||
case pushConnsAction:
|
case requestConnsAction:
|
||||||
g := c.group
|
g := c.group
|
||||||
if g == nil || a.group != g {
|
if g == nil || a.group != g {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
for _, u := range c.up {
|
for _, u := range c.up {
|
||||||
|
if a.id != "" && a.id != u.id {
|
||||||
|
continue
|
||||||
|
}
|
||||||
tracks := u.getTracks()
|
tracks := u.getTracks()
|
||||||
replace := u.getReplace(false)
|
replace := u.getReplace(false)
|
||||||
|
|
||||||
|
@ -946,7 +951,7 @@ func handleAction(c *webClient, a interface{}) error {
|
||||||
for i, t := range tracks {
|
for i, t := range tracks {
|
||||||
ts[i] = t
|
ts[i] = t
|
||||||
}
|
}
|
||||||
err := a.client.PushConn(g, u.id, u, ts, replace)
|
err := a.target.PushConn(g, u.id, u, ts, replace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("PushConn: %v", err)
|
log.Printf("PushConn: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -1417,7 +1422,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
|
||||||
disk.Close()
|
disk.Close()
|
||||||
return c.error(err)
|
return c.error(err)
|
||||||
}
|
}
|
||||||
pushConns(disk, c.group)
|
requestConns(disk, c.group, "")
|
||||||
case "unrecord":
|
case "unrecord":
|
||||||
if !c.permissions.Record {
|
if !c.permissions.Record {
|
||||||
return c.error(group.UserError("not authorised"))
|
return c.error(group.UserError("not authorised"))
|
||||||
|
|
Loading…
Reference in a new issue