waiting buffer process for a longer time

This commit is contained in:
Master Kwoth 2016-03-07 16:41:53 +01:00
parent d1dce345fb
commit 1bc681e1aa
3 changed files with 19 additions and 9 deletions

View File

@ -157,10 +157,10 @@ namespace NadekoBot.Classes.Music {
return; return;
} }
if (read == 0) if (read == 0)
if (attempt++ == 20) if (attempt++ == 50)
break; break;
else else
await Task.Delay(40, cancelToken); await Task.Delay(100, cancelToken);
else else
attempt = 0; attempt = 0;
await songBuffer.WriteAsync(buffer, read, cancelToken); await songBuffer.WriteAsync(buffer, read, cancelToken);
@ -207,7 +207,6 @@ namespace NadekoBot.Classes.Music {
var read = songBuffer.Read(buffer, blockSize); var read = songBuffer.Read(buffer, blockSize);
if (read == 0) if (read == 0)
if (attempt++ == 20) { if (attempt++ == 20) {
Console.WriteLine("Waiting to empty out buffer.");
voiceClient.Wait(); voiceClient.Wait();
Console.WriteLine($"Song finished. [{songBuffer.ContentLength}]"); Console.WriteLine($"Song finished. [{songBuffer.ContentLength}]");
break; break;
@ -222,7 +221,9 @@ namespace NadekoBot.Classes.Music {
buffer = AdjustVolume(buffer, MusicPlayer.Volume); buffer = AdjustVolume(buffer, MusicPlayer.Volume);
voiceClient.Send(buffer, 0, read); voiceClient.Send(buffer, 0, read);
} }
Console.WriteLine("Awiting buffer task");
await bufferTask; await bufferTask;
Console.WriteLine("Buffer task done.");
voiceClient.Clear(); voiceClient.Clear();
cancelToken.ThrowIfCancellationRequested(); cancelToken.ThrowIfCancellationRequested();
} }

View File

@ -39,13 +39,22 @@ namespace NadekoBot.Commands {
NadekoBot.Client.MessageUpdated += MsgUpdtd; NadekoBot.Client.MessageUpdated += MsgUpdtd;
NadekoBot.Client.UserUpdated += UsrUpdtd; NadekoBot.Client.UserUpdated += UsrUpdtd;
//if (NadekoBot.Config.SendPrivateMessageOnMention) if (NadekoBot.Config.SendPrivateMessageOnMention)
// NadekoBot.Client.MessageReceived += async (s, e) => { NadekoBot.Client.MessageReceived += async (s, e) => {
// if (e.Channel.IsPrivate) try {
// return; if (e.Channel.IsPrivate)
// if (e.Message.MentionedUsers.Any()) return;
var usr = e.Message.MentionedUsers.FirstOrDefault(u => u != e.User);
if (usr?.Status != UserStatus.Offline)
return;
await e.Channel.SendMessage($"User `{usr.Name}` is offline. PM sent.");
await usr.SendMessage(
$"User `{e.User.Name}` mentioned you on " +
$"`{e.Server.Name}` server while you were offline.\n" +
$"`Message:` {e.Message.Text}");
// }; } catch { }
};
} }
public Func<CommandEventArgs, Task> DoFunc() => async e => { public Func<CommandEventArgs, Task> DoFunc() => async e => {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 1.2 MiB