Fixed a few voice crashes
This commit is contained in:
@@ -22,10 +22,13 @@ namespace Discord
|
||||
public async Task LeaveVoiceServer()
|
||||
{
|
||||
CheckReady(checkVoice: true);
|
||||
|
||||
await _voiceSocket.Disconnect().ConfigureAwait(false);
|
||||
await TaskHelper.CompletedTask.ConfigureAwait(false);
|
||||
_dataSocket.SendLeaveVoice();
|
||||
|
||||
if (_voiceSocket.CurrentVoiceServerId != null)
|
||||
{
|
||||
await _voiceSocket.Disconnect().ConfigureAwait(false);
|
||||
await TaskHelper.CompletedTask.ConfigureAwait(false);
|
||||
_dataSocket.SendLeaveVoice();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Sends a PCM frame to the voice server. </summary>
|
||||
|
||||
@@ -52,23 +52,14 @@ namespace Discord.Net.WebSockets
|
||||
_targetAudioBufferLength = client.Config.VoiceBufferLength / 20; //20 ms frames
|
||||
}
|
||||
|
||||
public async Task Login(string host, string serverId, string userId, string sessionId, string token)
|
||||
public Task Login(string host, string serverId, string userId, string sessionId, string token)
|
||||
{
|
||||
_serverId = serverId;
|
||||
_userId = userId;
|
||||
_sessionId = sessionId;
|
||||
_token = token;
|
||||
|
||||
await base.Connect(host);
|
||||
|
||||
Commands.Login msg = new Commands.Login();
|
||||
msg.Payload.Token = token;
|
||||
//msg.Payload.Properties["$os"] = "";
|
||||
//msg.Payload.Properties["$browser"] = "";
|
||||
msg.Payload.Properties["$device"] = "Discord.Net";
|
||||
//msg.Payload.Properties["$referrer"] = "";
|
||||
//msg.Payload.Properties["$referring_domain"] = "";
|
||||
QueueMessage(msg);
|
||||
return base.Connect(host);
|
||||
}
|
||||
|
||||
protected override Task[] Run()
|
||||
@@ -405,7 +396,7 @@ namespace Discord.Net.WebSockets
|
||||
int frameSize = _encoder.FrameSize;
|
||||
int frames = bytes / frameSize;
|
||||
int expectedBytes = frames * frameSize;
|
||||
int lastFrameSize = expectedBytes - bytes;
|
||||
int lastFrameSize = bytes - expectedBytes;
|
||||
|
||||
//If this only consists of a partial frame and the buffer is too small to pad the end, make a new one
|
||||
if (data.Length < frameSize)
|
||||
|
||||
Reference in New Issue
Block a user