예제 #1
0
        private async Task UpdateSends(System.Threading.CancellationToken newListener)
        {
            foreach (var kvpSpeaker in ConnectedChannels)
            {
                IAudioClient speaker = kvpSpeaker.Value;
                await speaker.SetSpeakingAsync(true);

                AudioOutStream speak = speaker.CreateDirectOpusStream();
                Console.WriteLine("Speaker");
                foreach (var kvpListener in ConnectedChannels.Where(c => !speaker.Equals(c)))
                {
                    Console.WriteLine("Listener");
                    IAudioClient listener = kvpListener.Value;
                    await kvpListener.Value.CreateOpusStream().CopyToAsync(speaker.CreateOpusStream());

                    var users = (await(listener as IVoiceChannel).GetUsersAsync().FlattenAsync()).Where(u => !u.IsBot);
                    foreach (var user in users)
                    {
                        await ListenUserAsync(user).CopyToAsync(speak);
                    }
                }
                await speak.WriteAsync(new byte[3840], newListener);

                await speaker.SetSpeakingAsync(false);
            }
        }