Commit caa22643 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Close up connections when presenter permission lost.

parent 3ea63c39
......@@ -205,6 +205,16 @@ func getUpConn(c *client, id string) *upConnection {
return conn
}
func getUpConns(c *client) []string {
c.group.mu.Lock()
defer c.group.mu.Unlock()
up := make([]string, 0, len(c.up))
for id := range c.up {
up = append(up, id)
}
return up
}
func addUpConn(c *client, id string) (*upConnection, error) {
pc, err := groups.api.NewPeerConnection(iceConfiguration())
if err != nil {
......@@ -740,11 +750,21 @@ func clientLoop(c *client, conn *websocket.Conn) error {
}
}
case sendPermissionsAction:
case permissionsChangedAction:
c.write(clientMessage{
Type: "permissions",
Permissions: c.permissions,
})
if(!c.permissions.Present) {
ids := getUpConns(c)
for _, id := range ids {
c.write(clientMessage{
Type: "abort",
Id: id,
})
delUpConn(c, id)
}
}
case kickAction:
return userError("you have been kicked")
default:
......
......@@ -84,7 +84,7 @@ type pushTracksAction struct {
c *client
}
type sendPermissionsAction struct{}
type permissionsChangedAction struct{}
type kickAction struct{}
......@@ -424,7 +424,7 @@ func setPermission(g *group, id string, perm string) error {
default:
return userError("unknown permission")
}
return c.action(sendPermissionsAction{})
return c.action(permissionsChangedAction{})
}
func kickClient(g *group, id string) error {
......
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