-
-
Save richard1122/8b8ca492fa7c8faf7432bc0b19d2df7a to your computer and use it in GitHub Desktop.
wukong
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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