public ReplyData get_location(IPAddress remoteIP, int remotePort, List <string> arguments, string body, string method, Dictionary <string, string> Headers) { ReplyData rd = new ReplyData(); Console.WriteLine("====> Request: Get_Location"); UserAccounts UA = UserAccounts.GetAccounts(); UserAccounts.Location loc = UA.GetLocation(arguments[0]); LocationPacket lp = new LocationPacket(); if (loc.network_address != "") { lp.status = "success"; lp.location = loc; } else { lp.status = "user has no location"; } rd.Status = 200; rd.Body = JsonConvert.SerializeObject(lp); return(rd); }
public RESTReplyData user_location_set(RESTRequestData pReq, List <string> pArgs) { ResponseBody respBody = new ResponseBody(); if (Users.Instance.TryGetUserWithAuth(pReq.AuthToken, out UserEntity aUser)) { LocationPacket loc = pReq.RequestBodyObject <LocationPacket>(); // TODO: do whatever putting the location does } else { respBody.Status = "fail"; } return(new RESTReplyData(respBody)); }
public ReplyData user_location_set(IPAddress remoteIP, int remotePort, List <string> arguments, string body, string method, Dictionary <string, string> Headers) { LocationPacket loc = JsonConvert.DeserializeObject <LocationPacket>(body); string AccessToken = Headers["Authorization"].Split(new[] { ' ' })[1]; UserAccounts UA = UserAccounts.GetAccounts(); UA.UpdateLocation(loc.location, AccessToken); replyPacket rp = new replyPacket(); rp.status = "success"; rp.data = "no error"; ReplyData rd = new ReplyData(); rd.Status = 200; rd.Body = JsonConvert.SerializeObject(rp); return(rd); }
public static void locationChange(GameLocation oldLoc, GameLocation newLoc) { string newLocName = getUniqueLocationName(newLoc); Log.Async("(Me) " + SaveGame.loaded.player.name + " moved to " + newLocName + " (" + newLoc + ")"); LocationPacket loc = new LocationPacket(getMyId(), newLocName); MovingStatePacket move = new MovingStatePacket(getMyId(), Game1.player); if (!goingToFestival) { Multiplayer.sendFunc(loc); } Multiplayer.sendFunc(move); if (Multiplayer.mode == Mode.Host && server.playing) { // Move everyone to the festival if (newLocName == "Temp" && Game1.player.currentLocation.currentEvent != null) { foreach (Server.Client other in server.clients) { if (other.farmer.currentLocation != null) { other.farmer.currentLocation.farmers.Remove(other.farmer); } other.farmer.currentLocation = Game1.player.currentLocation; other.farmer.currentLocation.farmers.Add(other.farmer); } goingToFestival = false; } else if (oldLoc.Name == "Temp") { foreach (Server.Client other in server.clients) { if (other.farmer.currentLocation != oldLoc) { continue; } other.farmer.currentLocation.farmers.Remove(other.farmer); other.farmer.currentLocation = Game1.player.currentLocation; other.farmer.currentLocation.farmers.Add(other.farmer); } } } else if (Multiplayer.mode == Mode.Client && client.stage == Client.NetStage.Playing) { if (newLocName == "Temp" && Game1.player.currentLocation.currentEvent != null) { foreach (KeyValuePair <byte, Farmer> other in client.others) { if (other.Value.currentLocation != null) { other.Value.currentLocation.farmers.Remove(other.Value); } other.Value.currentLocation = Game1.player.currentLocation; other.Value.currentLocation.farmers.Add(other.Value); } goingToFestival = false; } else if (oldLoc.Name == "Temp") { foreach (KeyValuePair <byte, Farmer> other in client.others) { if (other.Value.currentLocation != oldLoc) { continue; } other.Value.currentLocation.farmers.Remove(other.Value); other.Value.currentLocation = Game1.player.currentLocation; other.Value.currentLocation.farmers.Add(other.Value); } } } }