コード例 #1
0
 public void Challenge(IFoosPlayer playerToChallenge)
 {
     Task.Factory.StartNew(() =>
     {
         Thread.Sleep(2000);
         var repsonse = new ChallengeResponse(playerToChallenge, m_Random.Next(2) == 0);
         if (ChallengeResponse != null) ChallengeResponse(repsonse);
     });
 }
コード例 #2
0
ファイル: FoosNetworkService.cs プロジェクト: rba100/foosnet
 public void Respond(ChallengeResponse response)
 {
     m_WebSocket.SendAsJson(new { action = "respond", challenger = response.Player.Email, response = response.Accepted.ToString() });
 }
コード例 #3
0
ファイル: GameManager.cs プロジェクト: rba100/foosnet
        private void NetworkServiceOnChallengeResponse(ChallengeResponse challengeResponse)
        {
            var player = m_PlayerLineUp.FirstOrDefault(p => p.Email.Equals(challengeResponse.Player.Email, StringComparison.OrdinalIgnoreCase));
            if (player != null)
            {
                player.GameState = challengeResponse.Accepted ? GameState.Accepted : GameState.Declined;
                if (player.GameState == GameState.Declined) RemovePlayer(player);

                if (IsGameReadyToStart)
                {
                    StatusMessage = c_ReadyToStart;
                    // This property is not automatically updated because it's a computed value
                    OnPropertyChanged("IsGameReadyToStart");
                }
            }
            else
            {
                if (challengeResponse.Accepted)
                {
                    m_NetworkService.CancelGame(new[] { challengeResponse.Player });
                }
            }
        }
コード例 #4
0
 public void Respond(ChallengeResponse response)
 {
 }