Answer the question
In order to leave comments, you need to log in
Push notifications vs sockets?
I need to write the server part of a mobile application, where one of the tasks is to exchange locations between users. That is, users can track each other's movement.
1) How do you usually write such things?
2) If the socket is better to use PHP or Java for this? Or is there no difference?
Answer the question
In order to leave comments, you need to log in
1. Through pushes, there is a chance that the user will disable pushes in the settings, and then the whole application will be closed
. better parallel and there are good servers: netty, vert.x or akka :) . PHP is built to die
The simplest thing is to make a request to the server every N seconds, sending your coordinates (receiving them using GPS or GLONASS) and receiving in response the coordinates of the second person and possibly some additional parameters.
If you need to work with coordinates in the database on a server (calculating distance, selecting a region of points, etc.), then I advise PostgreSQL together with PostGIS
It's usually written like this .
It is enough to use get in batch mode:
1 request: sending and receiving the necessary data (json).
PS: PHP sockets work fine, but there are nuances. (configured as I need)
Try this:
1. You send a UDP packet to the server
2. When the packet arrives, you update your status that you are online and at the same time your address.
3. Search for a list of online friends
4. Send them UDP response packets
If they get lost, it's not a problem, it's geo data, but it works easier than TCP and faster. I recommend using Netty as a server.
This is just an assumption, not a fact that it will work.
PS if your application is simple with a white IP, you can do without a server at all.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question