//------------------------------------------------------------- public void GotAlreadyOwnIt(DTO_AlreadyOwnIt alreadyOwnIt) //------------------------------------------------------------- { SuggestedGame suggestedGameControl = suggestedGames.Where(L => L.GetKey().Equals(alreadyOwnIt.key) && L.GetType() == typeof(SuggestedGameOwnerControl)).FirstOrDefault(); if (suggestedGameControl == null) { Log.Get().Write("KobberLan DTO_AlreadyOwnIt unknown title: " + alreadyOwnIt.key, Log.LogType.Error); } else { ((SuggestedGameOwnerControl)suggestedGameControl).IncreasePeer(alreadyOwnIt.address.ToString()); } }
//------------------------------------------------------------- public void AddSuggestedGame(DTO_Suggestion suggestion, string path = null, bool ownSuggestions = false, string remoteIP = "") //------------------------------------------------------------- { //Check if title exist if (!suggestedGames.Any(L => L.GetKey().Equals(suggestion.key))) { //Add suggested game SuggestedGame suggestedGame; if (suggestion.type == SuggestionType.Internet) { suggestedGame = new SuggestedGameInternetControl(suggestion, this); } else if (ownSuggestions) { //Add game as owner suggestedGame = new SuggestedGameOwnerControl(suggestion, path, this, ownSuggestions); } else { suggestedGame = new SuggestedGameControl(suggestion, this); if (Directory.Exists(Helper.GetDirection() + "\\" + suggestion.key)) { //Already own the game, tell server about it DTO_AlreadyOwnIt alreadyOwnIt = new DTO_AlreadyOwnIt() { address = Helper.GetHostIP(), key = suggestion.key }; communication.ClientSend(alreadyOwnIt, remoteIP); } } flowLayoutPanel_SuggestedGames.Controls.Add(suggestedGame); suggestedGames.Add(suggestedGame); } else { //Warning, tried to add already exisiting game Log.Get().Write("Game " + suggestion.key + " already exist. Note this would happen if BroadCast is active, all player gets suggested game again.", Log.LogType.Info); } }