diff --git a/voice/udp/manager.go b/voice/udp/manager.go index dc7e359..15e871a 100644 --- a/voice/udp/manager.go +++ b/voice/udp/manager.go @@ -28,6 +28,7 @@ type Manager struct { // conn state conn *Connection + prevConn *Connection connLock chan struct{} frequency time.Duration @@ -69,6 +70,7 @@ func (m *Manager) Pause(ctx context.Context) error { case <-ctx.Done(): return ctx.Err() case m.connLock <- struct{}{}: + m.prevConn = m.conn return nil } } @@ -113,6 +115,11 @@ func (m *Manager) IsClosed() bool { func (m *Manager) Continue() bool { ws.WSDebug("UDP continued") + if m.prevConn != nil { + m.prevConn.Close() + m.prevConn = nil + } + select { case <-m.connLock: return true