public async void AnimationIdled([FromBody] string fighterIdAndSessionId) { var tuple = Newtonsoft.Json.JsonConvert.DeserializeObject <Tuple <string, string> >(fighterIdAndSessionId); string fighterId = tuple.Item1; string sessionId = tuple.Item2; //flip the semaphore for this fighter, indicating it has reentered idle and; _combatManager.Sessions[sessionId].AnimationSemaphore[fighterId] = true; //check to see if both fighters are now idled. if so, clear out both semaphores and send out signaR notification if (_combatManager.Sessions[sessionId].AnimationSemaphore.Where(x => x.Value).Count() == 2) { List <string> keys = _combatManager.Sessions[sessionId].AnimationSemaphore.Keys.ToList <string>(); foreach (string key in keys) { if (_combatManager.Sessions[sessionId].AnimationSemaphore[key]) { _combatManager.Sessions[sessionId].AnimationSemaphore[key] = false; } } List <string> playerIds = new List <string>(); playerIds.Add(_combatManager.Sessions[sessionId].Player1Id); playerIds.Add(_combatManager.Sessions[sessionId].Player2Id); await _chatHubContext.SendAnimationsIdled(playerIds, "ok"); } }
public async void AnimationIdled([FromBody] string fighterId) { if (_combatManager.setSemaphore(fighterId)) { //CombatSession thisCombatSession = _combatManager.GetCombatSessionByFighterId(fighterId); //List<string> keys = thisCombatSession.AnimationSemaphore.Keys.ToList<string>(); //List<string> playerIds = new List<string>(); //playerIds.AddRange // ( // _combatManager.GetCombatSessionByFighterId(fighterId).Fighters.Select(x => x.Value.ownerId) // ); //await _chatHubContext.SendAnimationsIdled(playerIds, "ok"); await _chatHubContext.SendAnimationsIdled( _combatManager.GetCombatSessionByFighterId(fighterId).Fighters.Select(x => x.Value.ownerId).ToList() , "ok"); } }