private async Task Work() { Room room = null; string[] parserUri = null; var context = await listener.GetContextAsync(); parserUri = context.Request.RawUrl.ToString().Split('/'); room = SwitchGame.GetGame(parserUri[1]); if (parserUri[2] == "AddXeshInRoom") { listRoom.Find(r => r.Key == parserUri[3]).listObserversUser.Add(Server.Server.listUser.Find(u => u.LogIn == parserUri[3])); } else if (room.TypeGame == "WindowGame") { room.Init(parserUri[1], GetIdRoom(), parserUri[2]); room.listObserversUser.Add(Server.Server.listUser.Find(u => u.LogIn == parserUri[3])); room.Key = GetKeyRoom(); listRoom.Add(room); Response(context, $"{room.NameGame}/{room.id.ToString()}/{room.Key}/{room.TypeRoom}"); if (room.TypeRoom == "public") { PushAllRoom(room).GetAwaiter().GetResult(); } room = null; } }
/// <summary> /// Queries the CDN for all versions of a game /// </summary> /// <param name="game"></param> /// <returns></returns> public List <string> GetVersions(SwitchGame game) { //string url = string.Format("https://tagaya.hac.{0}.eshop.nintendo.net/tagaya/hac_versionlist", env); string url = string.Format("https://superfly.hac.{0}.d4c.nintendo.net/v1/t/{1}/dv", environment, game.TitleID); string result = MakeRequest(HttpMethod.Get, url, null, null); Dictionary <string, string> json = JsonConvert.DeserializeObject <Dictionary <string, string> >(result); string sLatestVersion = json["version"]; int latestVersion = int.Parse(sLatestVersion); List <string> versions = new List <string>(); if (latestVersion < 65536) { versions.Add(sLatestVersion); } else { versions.Add(sLatestVersion); } return(versions); /* * lastestVer = j['version'] * if lastestVer < 65536: * return ['%s' % lastestVer] * else: * versionList = ('%s' % "-".join(str(i) for i in range(0x10000, lastestVer + 1, 0x10000))).split('-') * return versionList * except Exception as e: * return ['none'] * */ }
public void UpdateSwitchGame(SwitchUpdateModel switchToUpdate) { using (var ctx = new ApplicationDbContext()) { SwitchGame switchWeWantToUpdate = ctx.SwitchGames.Find(switchToUpdate.Name); if (switchToUpdate != null) { switchWeWantToUpdate.Name = switchToUpdate.Name; switchWeWantToUpdate.Price = switchToUpdate.Price; switchWeWantToUpdate.Rating = switchToUpdate.Rating; ctx.SaveChanges(); } } }
public void CreateSwitchGame(SwitchCreateModel model) { var switchToCreate = new SwitchGame() { Name = model.Name, Price = model.Price, Genre = model.Genre, MaturityRating = model.MaturityRating, Rating = model.Rating, DeveloperId = model.DeveloperId, PublisherId = model.PublisherId }; using (ApplicationDbContext ctx = new ApplicationDbContext()) { ctx.SwitchGames.Add(switchToCreate); ctx.SaveChanges(); } }
/// <summary> /// Loads a remote image from nintendo. /// /// This is way more complicated and I know I'm gonna need more arguments passed in. /// Not implemented for now. /// </summary> /// <param name="titleID"></param> /// <returns></returns> public SwitchImage GetRemoteImage(SwitchGame game) { string n = "0"; string titleID = game.TitleID; string baseVersion; if (game.Versions.Count == 0) { baseVersion = "0"; } else { baseVersion = game.Versions.Last(); } string url = string.Format(remotePathPattern, n, environment, titleID, baseVersion, deviceId); MakeRequest(HttpMethod.Head, url, null, null); return(new SwitchImage("Images\\blank.jpg")); }