1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-09 18:25:58 +01:00

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 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) { func addUpConn(c *client, id string) (*upConnection, error) {
pc, err := groups.api.NewPeerConnection(iceConfiguration()) pc, err := groups.api.NewPeerConnection(iceConfiguration())
if err != nil { if err != nil {
@ -740,11 +750,21 @@ func clientLoop(c *client, conn *websocket.Conn) error {
} }
} }
case sendPermissionsAction: case permissionsChangedAction:
c.write(clientMessage{ c.write(clientMessage{
Type: "permissions", Type: "permissions",
Permissions: c.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: case kickAction:
return userError("you have been kicked") return userError("you have been kicked")
default: default:

View file

@ -84,7 +84,7 @@ type pushTracksAction struct {
c *client c *client
} }
type sendPermissionsAction struct{} type permissionsChangedAction struct{}
type kickAction struct{} type kickAction struct{}
@ -424,7 +424,7 @@ func setPermission(g *group, id string, perm string) error {
default: default:
return userError("unknown permission") return userError("unknown permission")
} }
return c.action(sendPermissionsAction{}) return c.action(permissionsChangedAction{})
} }
func kickClient(g *group, id string) error { func kickClient(g *group, id string) error {