1
Fork 0

Close up connections when presenter permission lost.

This commit is contained in:
Juliusz Chroboczek 2020-04-25 18:35:32 +02:00
parent 3ea63c394c
commit caa2264390
2 changed files with 23 additions and 3 deletions

View File

@ -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:

View File

@ -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 {