Commit 515c4a5c authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Rename pushConns to requestConns, move into Client interface.

Also allow selecting just a single connection.
parent 435f46c5
...@@ -79,6 +79,10 @@ func (client *Client) PushClient(id, username string, permissions *group.ClientP ...@@ -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 { ...@@ -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 { ...@@ -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 { func requestConns(target group.Client, g *group.Group, id string) {
ccc.action(pushConnsAction{g, c}) clients := g.GetClients(target)
} for _, c := range clients {
c.RequestConns(target, g, id)
} }
} }
...@@ -801,9 +802,10 @@ type pushConnAction struct { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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"))
......
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