I will give a banal example about taxis. The client orders a taxi and presses the order button, then the data went to the server and the order went to the taxi driver. When the order is received, the answer goes to the server with data about the driver or with what they come there (it does not matter). The client receives an answer and looks for information about the driver.

How does the customer get a response with the information? After all, after sending there, everything does not happen right away, for some time the order weighs in anticipation until it is accepted and then the data from the information is received to the specific client when the order is accepted.

How to make a similar thing, maybe there is material on this topic or something else that you can advise to read.

  • GCM and his ilk - ermak0ff
  • Googling things like longpoll - Victor Evlampiev
  • GCM or WebSocket - Chaynik

1 answer 1

Usually this functionality is done via Socket or WebSocket.

Thus, all taxi drivers and all clients are hacked to the same server.

Accordingly, all connected to the server can both send information to it, and receive data from it.

I.e:

The client sent a request for a taxi through the socket. The server processed the request, passed the order information to all taxi drivers in the specified area using the same sockets. The taxi driver saw the order, clicked to agree on the order and sent a request to the server to accept the order. The server saw a request from the taxi driver and sent information about it to the client. The client caught it in the application, the UI was updated and the information about the taxi driver is visible to the client. In this case, while the order is not accepted in the same way, the taxi driver can provide the client with data about his location, for example.

You can look at the simplest example.

In more complex cases, it is better to create a separate stream for each socket connection, use the database on the server to save some permanent data, and so on.