示例#1
0
        private Task Stage2(VoiceSessionDescriptionPayload voiceSessionDescription)
        {
            SelectedEncryptionMode = Sodium.SupportedModes[voiceSessionDescription.Mode.ToLowerInvariant()];
            Discord.DebugLogger.LogMessage(LogLevel.Debug, "VoiceNext", $"Discord updated encryption mode: {SelectedEncryptionMode}", DateTime.Now);

            // start keepalive
            KeepaliveTokenSource = new CancellationTokenSource();
            KeepaliveTask        = KeepaliveAsync();

            // send 3 packets of silence to get things going
            var nullpcm = new byte[AudioFormat.CalculateSampleSize(20)];

            for (var i = 0; i < 3; i++)
            {
                var nullopus    = new byte[nullpcm.Length];
                var nullopusmem = nullopus.AsMemory();
                PreparePacket(nullpcm, ref nullopusmem);
                EnqueuePacket(new VoicePacket(nullopusmem, 20));
            }

            IsInitialized = true;
            ReadyWait.SetResult(true);

            return(Task.Delay(0));
        }
        private Task Stage2(VoiceSessionDescriptionPayload voiceSessionDescription)
        {
            this.SelectedEncryptionMode = Sodium.SupportedModes[voiceSessionDescription.Mode.ToLowerInvariant()];
            this.Discord.Logger.LogTrace(VoiceNextEvents.VoiceHandshake, "Discord updated encryption mode - new mode is {0}", this.SelectedEncryptionMode);

            // start keepalive
            this.KeepaliveTokenSource = new CancellationTokenSource();
            this.KeepaliveTask        = this.KeepaliveAsync();

            // send 3 packets of silence to get things going
            var nullpcm = new byte[this.AudioFormat.CalculateSampleSize(20)];

            for (var i = 0; i < 3; i++)
            {
                var nullopus    = new byte[nullpcm.Length];
                var nullopusmem = nullopus.AsMemory();
                this.PreparePacket(nullpcm, ref nullopusmem);
                this.EnqueuePacket(new VoicePacket(nullopusmem, 20));
            }

            this.IsInitialized = true;
            this.ReadyWait.SetResult(true);

            return(Task.CompletedTask);
        }
示例#3
0
        private async Task Stage2(VoiceSessionDescriptionPayload voiceSessionDescription)
        {
            this.SelectedEncryptionMode = Sodium.SupportedModes[voiceSessionDescription.Mode.ToLowerInvariant()];
            this.Discord.DebugLogger.LogMessage(LogLevel.Debug, "VoiceNext", $"Discord updated encryption mode: {this.SelectedEncryptionMode}", DateTime.Now);

            // start keepalive
            if (this.KeepaliveTokenSource != null)
            {
                this.KeepaliveTokenSource.Cancel();
            }
            this.KeepaliveTokenSource = new CancellationTokenSource();
            this.KeepaliveTask        = this.KeepaliveAsync();

            if (!this.IsInitialized)
            {
                this.IsInitialized = true;
                this.ReadyWait.SetResult(true);
            }

            await this.ResumeAsync();
        }