Automatically toggle speaking boolean

This commit is contained in:
RogueException
2017-04-03 19:59:03 -03:00
parent af7943e62a
commit e49122ea7e
3 changed files with 14 additions and 1 deletions

View File

@@ -6,6 +6,8 @@ namespace Discord.Audio.Streams
///<summary> Wraps an IAudioClient, sending voice data on write. </summary>
public class OutputStream : AudioOutStream
{
private bool _isSpeaking;
private readonly DiscordVoiceAPIClient _client;
public OutputStream(IAudioClient client)
: this((client as AudioClient).ApiClient) { }
@@ -14,6 +16,14 @@ namespace Discord.Audio.Streams
_client = client;
}
public async Task SetSpeakingAsync(bool isSpeaking)
{
if (_isSpeaking != isSpeaking)
{
await _client.SendSetSpeaking(isSpeaking).ConfigureAwait(false);
_isSpeaking = isSpeaking;
}
}
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancelToken)
{
cancelToken.ThrowIfCancellationRequested();