Rework connection replacement.
We used to signal connection replacement by reusing the same connection id. This turned out to be racy, as we couldn't reliably discard old answers after a connection id was refused. We now use a new id for every new connection, and explicitly signal stream replacement in the offer message. This requires maintaining a local id on the client side.
This commit is contained in:
@@ -93,7 +93,7 @@ func (client *Client) Kick(id, user, message string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (client *Client) PushConn(g *group.Group, id string, up conn.Up, tracks []conn.UpTrack) error {
|
||||
func (client *Client) PushConn(g *group.Group, id string, up conn.Up, tracks []conn.UpTrack, replace string) error {
|
||||
if client.group != g {
|
||||
return nil
|
||||
}
|
||||
@@ -105,6 +105,14 @@ func (client *Client) PushConn(g *group.Group, id string, up conn.Up, tracks []c
|
||||
return errors.New("disk client is closed")
|
||||
}
|
||||
|
||||
rp := client.down[replace]
|
||||
if rp != nil {
|
||||
rp.Close()
|
||||
delete(client.down, replace)
|
||||
} else {
|
||||
log.Printf("Replacing unknown connection")
|
||||
}
|
||||
|
||||
old := client.down[id]
|
||||
if old != nil {
|
||||
old.Close()
|
||||
|
||||
Reference in New Issue
Block a user