Skip to content

Instantly share code, notes, and snippets.

@richard1122
Created November 8, 2019 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richard1122/8b8ca492fa7c8faf7432bc0b19d2df7a to your computer and use it in GitHub Desktop.
Save richard1122/8b8ca492fa7c8faf7432bc0b19d2df7a to your computer and use it in GitHub Desktop.
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