Exemple #1
0
 /// <summary>
 /// reinitialize game to create new one
 /// </summary>
 /// <returns></returns>
 public async Task ReinitGame()
 {
     _blackjackGame  = new BlackjackGame();
     _messageBuilder = new BlackjackMessageBuilder(_blackjackGame);
     foreach (var entry in Websockets.ToList())
     {
         var wrapper = entry.Value;
         var user    = wrapper.BlackjackUser;
         if (user == null)
         {
             continue;
         }
         user = user.Reinit();
         _blackjackGame.AddUser(wrapper.Place, user);
     }
     await CheckStartGame(false);
 }
Exemple #2
0
        public async Task SendGameInfoWithTask(Func <BlackjackUser, int, Dictionary <string, object> > t)
        {
            var socketsToRemove = new List <string>();

            foreach (var websocketWrapper in Websockets.ToList())
            {
                var wrapper = websocketWrapper.Value;
                try
                {
                    await SendMessageJson(wrapper.WebSocket,
                                          t(wrapper.BlackjackUser, wrapper.Place));
                }
                catch (Exception e)
                {
                    socketsToRemove.Add(websocketWrapper.Key);
                }
            }
            foreach (var key in socketsToRemove)
            {
                Websockets.Remove(key);
            }
        }