diff --git a/internal/telemost/peer.go b/internal/telemost/peer.go index 3d68cde..cf9efe0 100644 --- a/internal/telemost/peer.go +++ b/internal/telemost/peer.go @@ -938,10 +938,6 @@ func (p *Peer) reconnect(ctx context.Context) error { p.reconnecting.Store(true) defer p.reconnecting.Store(false) - if p.onReconnect != nil { - p.onReconnect(nil) - } - p.sendLeave(uuid.New().String()) time.Sleep(500 * time.Millisecond) p.stopSession() @@ -964,6 +960,10 @@ func (p *Peer) reconnect(ctx context.Context) error { p.wsMu.Unlock() } + if p.onReconnect != nil { + p.onReconnect(nil) + } + time.Sleep(3 * time.Second) conn, err := GetConnectionInfo(ctx, p.roomURL, p.name) if err != nil {