From 145f058eaa9a311c4958f6a35477e22e747d6a34 Mon Sep 17 00:00:00 2001 From: David Colburn Date: Thu, 8 Jul 2021 01:37:21 -0500 Subject: [PATCH] send leave when client reconnects on server restart (#43) --- go.mod | 2 +- go.sum | 4 ++-- pkg/service/roommanager.go | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 013dc0092..d6ae44d3c 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/google/wire v0.5.0 github.com/gorilla/websocket v1.4.2 github.com/jxskiss/base62 v0.0.0-20191017122030-4f11678b909b - github.com/livekit/protocol v0.5.5 + github.com/livekit/protocol v0.5.6 github.com/magefile/mage v1.11.0 github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0 github.com/mitchellh/go-homedir v1.1.0 diff --git a/go.sum b/go.sum index 2bbc97862..46599c689 100644 --- a/go.sum +++ b/go.sum @@ -232,8 +232,8 @@ github.com/lithammer/shortuuid/v3 v3.0.6 h1:pr15YQyvhiSX/qPxncFtqk+v4xLEpOZObbsY github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts= github.com/livekit/ion-sfu v1.10.7-0.20210706220057-6c0f6eb24d59 h1:xltblvdgh94JRNnCM9z/cwVq9Dqh//l9SjxOlfFa1XQ= github.com/livekit/ion-sfu v1.10.7-0.20210706220057-6c0f6eb24d59/go.mod h1:Wx6b4qGUjvSo1kGl+/fHl0ZF48g2IJOjzUFg0yCo9qY= -github.com/livekit/protocol v0.5.5 h1:ZsfmTpaApf2o75qpJLP2f/FsCOwxW2sDJE3HKDa2OXE= -github.com/livekit/protocol v0.5.5/go.mod h1:wo3CGfYB7XMF8GoVJAfTARrYSP/ombi+sbLl6AYdKP0= +github.com/livekit/protocol v0.5.6 h1:vMUjYvJH2TD/WIjrXtG6aQl5fFrIj0/ZgIctQqmmwro= +github.com/livekit/protocol v0.5.6/go.mod h1:wo3CGfYB7XMF8GoVJAfTARrYSP/ombi+sbLl6AYdKP0= github.com/lucsky/cuid v1.0.2 h1:z4XlExeoderxoPj2/dxKOyPxe9RCOu7yNq9/XWxIUMQ= github.com/lucsky/cuid v1.0.2/go.mod h1:QaaJqckboimOmhRSJXSx/+IT+VTfxfPGSo/6mfgUfmE= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= diff --git a/pkg/service/roommanager.go b/pkg/service/roommanager.go index 2b04f96f6..78bd5ddcc 100644 --- a/pkg/service/roommanager.go +++ b/pkg/service/roommanager.go @@ -245,6 +245,19 @@ func (r *RoomManager) StartSession(roomName string, pi routing.ParticipantInit, // we need to clean up the existing participant, so a new one can join room.RemoveParticipant(participant.Identity()) } + } else if pi.Reconnect { + // send leave request if participant is trying to reconnect but missing from the room + if err = responseSink.WriteMessage(&livekit.SignalRequest{ + Message: &livekit.SignalRequest_Leave{ + Leave: &livekit.LeaveRequest{ + CanReconnect: true, + }, + }, + }); err != nil { + logger.Warnw("could not restart participant", err, + "participant", pi.Identity) + } + return } logger.Debugw("starting RTC session",