Ejemplo n.º 1
0
 private Task OnUserLeft(VoiceNextConnection vnc, VoiceUserLeaveEventArgs e)
 {
     if (this._ssrcFilemap.TryRemove(e.SSRC, out var pcmFs))
     {
         pcmFs.Dispose();
     }
     this._ssrcMap.TryRemove(e.SSRC, out _);
     return(Task.CompletedTask);
 }
        private static Task VoiceConnection_UserLeft(VoiceUserLeaveEventArgs e)
        {
            // ignore event if the channel isn't empty
            if (!IsEmptyVoiceChannel(e.Connection.Channel, e.User))
            {
                return(Task.CompletedTask);
            }

            Task.Run(async() =>
            {
                await Task.Delay(TimeSpan.FromSeconds(30));

                if (!IsEmptyVoiceChannel(e.Connection.Channel))
                {
                    return;
                }

                e.Connection.Disconnect();
            });

            // don't wait for the delayed task
            return(Task.CompletedTask);
        }