Skip to content

Instantly share code, notes, and snippets.

@richard1122 richard1122/wukong.cs Secret
Created Nov 8, 2019

Embed
What would you like to do?
wukong
private void CheckShouldForwardCurrentSong()
{
var userList = list.UserList;
var downVoteUserCount = downvoteUsers.Intersect(userList).Count;
var undeterminedCount = userList.Except(downvoteUsers).Except(finishedUsers).Count();
var connectedUserCount = userList.Select(it => socketManager.IsConnected(it)).Count();
if (!list.IsPlaying || downVoteUserCount >= QueryForceForwardCount(connectedUserCount) || undeterminedCount == 0)
{
ShouldForwardNow();
}
else if (undeterminedCount <= connectedUserCount * 0.5)
{
if (finishTimeoutTimer != null) return;
finishTimeoutTimer = new Timer(ShouldForwardNow, null, 5 * 1000, Infinite);
}
}
private static int QueryForceForwardCount(int total)
{
return Convert.ToInt32(Math.Ceiling((double)total / 2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.