Beispiel #1
0
        public ResponeCommMessage HandleEvent(SearchCommMessage msg)
        {
            if (_sessionIdHandler != null)
            {
                List <IGame> temp = new List <IGame>();
                switch (msg.searchType)
                {
                case SearchCommMessage.SearchType.ActiveGamesByUserName:
                    temp = _gameService.GetActiveGamesByUserName(msg.SearchByString);
                    break;

                case SearchCommMessage.SearchType.SpectetorGameByUserName:
                    temp = _gameService.GetSpectetorGamesByUserName(msg.SearchByString);
                    break;

                case SearchCommMessage.SearchType.ByRoomId:
                    IGame game = _gameService.GetGameById(msg.SearchByInt);
                    if (game != null)
                    {
                        temp.Add(game);
                    }
                    break;

                case SearchCommMessage.SearchType.AllSepctetorGame:
                    temp = _gameService.GetSpectateableGames();
                    break;

                case SearchCommMessage.SearchType.GamesUserCanJoin:
                    temp = _gameService.GetAllActiveGamesAUserCanJoin(msg.UserId);
                    break;

                case SearchCommMessage.SearchType.ByPotSize:
                    temp = _gameService.GetGamesByPotSize(msg.SearchByInt);
                    break;

                case SearchCommMessage.SearchType.ByGameMode:
                    temp = _gameService.GetGamesByGameMode(msg.SearchByGameMode);
                    break;

                case SearchCommMessage.SearchType.ByBuyInPolicy:
                    temp = _gameService.GetGamesByBuyInPolicy(msg.SearchByInt);
                    break;

                case SearchCommMessage.SearchType.ByMinPlayer:
                    temp = _gameService.GetGamesByMinPlayer(msg.SearchByInt);
                    break;

                case SearchCommMessage.SearchType.ByMaxPlayer:
                    temp = _gameService.GetGamesByMaxPlayer(msg.SearchByInt);
                    break;

                case SearchCommMessage.SearchType.ByStartingChip:
                    temp = _gameService.GetGamesByStartingChip(msg.SearchByInt);
                    break;

                case SearchCommMessage.SearchType.ByMinBet:
                    temp = _gameService.GetGamesByMinBet(msg.SearchByInt);
                    break;

                default:
                    break;
                }
                var toSend  = ToClientGameList(temp);
                var success = toSend.Count != 0;
                return(new SearchResponseCommMessage(toSend, _sessionIdHandler.GetSessionIdByUserId(msg.UserId),
                                                     msg.UserId, success, msg));
            }
            return(new ResponeCommMessage(msg.UserId, msg.SessionId, false, msg));
        }