C
C
cardexc2015-06-05 11:05:08
MySQL
cardexc, 2015-06-05 11:05:08

Data exchange with the server, algorithm of work, is it correct?

I am writing an application for tracking the location of the phone.
The exchange of android & mysql occurs through PHP scripts
General principle:
- user "A" sends a request to get the location of user "B";
Request data is stored in mysql database.
- the application of user "B" periodically polls the required mysql table in the database for a request (whether someone requested the location or not);
- if the application of user "B" sees that there is a request from someone, sends location data (recording to the mysql table on the server);
- the application of user "B" periodically checks whether the data has arrived from user "B", if yes, it downloads them.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Rytikov, 2015-06-05
@cardexc

Is this mode of operation needed to save battery and not update the user's current location, if no one needs it? I mean, why don't all users just periodically send the current location, but immediately give the last updated one on request and write how long ago it was received?
In your case, I see several possible problems:
1. Upon request, the user will not always be able to give the current location (or with insufficient accuracy).
2. Long response time to the request.
3. Most likely, you have already taken this point into account, but I will write it anyway. In your algorithm, the user must send a response about his location to all requests from all users. If requests for the location of one user arrive almost simultaneously, then there is no need to respond several times. If someone has already requested, and the user has not yet answered or answered some time ago, then you can not add a request to user B.

C
cardexc, 2015-06-05
@cardexc

why not just periodically send the current location to all users, but immediately give the last updated one on request and write how long ago it was received?

good idea. So I will probably do so.
Didn't take it into account. Thanks for the help!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question