public MarketClient(SteamMarketHandler steam) { this.steam = steam; this.Games = new AvailableGames(this.steam); this.Currencies = JsonConvert.DeserializeObject <Dictionary <string, string> >(Properties.Resources.Currencies); }
public void ReloadAvailableGames() { availableGames.Clear(); foreach (Game game in allGames) { if (!game.IsPlayed || game == allGames[allGames.Count - 1]) { continue; } availableGames.Add(GetNextGame(game)); if (availableGames.Contains(game)) { continue; } availableGames.Add(game); } if (!AvailableGames.Contains(allGames[0])) { availableGames.Add(allGames[0]); } player.ReloadAvailableChapter(); }
/// <summary> /// Raise the "AvailableGamesArrived" event. /// </summary> /// <param name="availableGames">The available games as received from the server.</param> private void NewAvailableGames(AvailableGames availableGames) { if (AvailableGamesArrived != null) { AvailableGamesArrived(this, new YachtAvailableGamesEventArgs() { AvailableGames = availableGames }); } }
public void Configuration(IAppBuilder app) { var config = new HttpConfiguration(); config.MapHttpAttributeRoutes(); config.Formatters.Remove(config.Formatters.XmlFormatter); config.Filters.Add(new LoadAttribute(100, 20)); //Local config var commandDispatcher = new Dispatcher <ICommand, Task>(); var availableGames = new AvailableGames(); var endedGames = new EndendGames(); //TODO log to trace //http://blog.amitapple.com/post/2014/06/azure-website-logging/#.VC6_jvmSyPY var eventPublisher = new EventPublisher(Console.WriteLine, new ProjectionEventListener(availableGames, endedGames)); var eventStore = new PublishingEventStore(new InMemoryEventStore(() => new InMemoryEventStream()), eventPublisher); commandDispatcher.Register <IGameCommand>( command => ApplicationService.UpdateAsync <Game.Domain.Game, GameState>( state => new Game.Domain.Game(state), eventStore, command, game => { CpuUtils.Slow(1500); return(game.Handle(command)); })); var cb = new ContainerBuilder(); cb.RegisterInstance(commandDispatcher).AsSelf().SingleInstance(); cb.RegisterType <ReadService>().AsImplementedInterfaces(); cb.RegisterInstance(availableGames).AsSelf().SingleInstance(); cb.RegisterInstance(endedGames).AsSelf().SingleInstance(); cb.RegisterApiControllers(Assembly.GetExecutingAssembly()); config.DependencyResolver = new AutofacWebApiDependencyResolver(cb.Build()); app.UseWebApi(config); app.Run(context => { context.Response.ContentType = "text/plain"; return(context.Response.WriteAsync("Welcome to RPS APi.")); }); }
public PlayerViewModel() { // When a game host is found. _participant.ManagerFound += (async(sender, e) => { var host = new GameHost() { Name = e.Message, Id = e.Id, CommChannel = _participant.CreateCommunicationChannel(e.Id) }; await callOnUiThread(() => AvailableGames.Add(host)); }); _participantCommunicationChannel = new TcpCommunicationChannel(); // When a new question is received from the game host. _participantCommunicationChannel.MessageReceived += (async(sender, e) => { object message = new Question(); e.GetDeserializedMessage(ref message); await callOnUiThread(() => CurrentQuestion = message as Question); }); }
public MarketClient(SteamMarketHandler steam, WebProxy proxy = null) { this.steam = steam; this.Games = new AvailableGames(this.steam); this.Proxy = proxy; }
/// <summary> /// Called when the list of available games arrives from the server. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Instance_AvailableGamesArrived(object sender, YachtAvailableGamesEventArgs e) { isSearching = false; searchAgain.Enabled = !isSearching; availableGames = e.AvailableGames; }