Reputation: 11
I am developing an android app, which uses maps to show the seller's location and user's location as they walk or get on a car, or ride a moto, etc. So, I was using a class in android, which sends an Url request . passig the latitude and longitude as parameters to the server in a GET method every 5 seconds, example: site.com.br?latitude1000&longitude2000. My question is how do I retrieve the last sent informations of the user's location from the server in real time, so that, I can get them and mark in the map, in the user's smartphone?
Upvotes: 1
Views: 59
Reputation: 851
If I understand your question in the right way .
This is a very bad practice.
However , you can save it in a session .
In the 5 sec Get request save it in a session variable that is unique to each user
$_Session['long']=$long;
$_Session['lat']=$lat;
Never save the entire get variable nor all the requested url ,also all variables stored in session should be sanitized. to get the variables again in any other request.
$long=$_Session['long'];
$lat=$_Session['lat'];
there is still much more approaches to complete the task , why not send them again in the next request?
The right way should be using web-socket , if you have the access to a vpn or a any service where you can install or use web-socket I recommend it as a must , sending request every 5 sec will have a lot of delay plus you will over load your server , also to mention the user will waist his valuable internet data plan
in brief with php websocket is a realtime 2 way way connection . I won't explain it here as it is off-topic
Upvotes: 1