1

How does app like Uber do real time tracking of Cabs? Let me put it across in detail:-

  1. Cabs Position to the server.
  2. Server then communicates that positionto the another user app which is trying to book a Cab.

I have gone through many blogs, after that I could think of the solution below to solve the 2 issues:

  1. Cabs will communicate there lat/long to server after some time gap using http request.
  2. The user app will establish a socket with the server and any change in the server will be communicated to the user app through that socket.

Is there a better way to do it? Please give your insight about the issue.

frogEye
  • 364
  • 3
  • 14
  • there is a method named `onLocationChanged(Location location)` in LocationListener class of android and it is `Called when the location has changed. ` so when cab changes its location it will be called and all you need is to send location to server. – karan Aug 03 '15 at 07:34
  • @KaranMer : if location is changing knowing that is not an issue but main concern is which one to use, polling or socket to communicate the info from Cab to server and then server to user app. Which one will be the smart chioce? – frogEye Aug 03 '15 at 07:40
  • then check this out http://stackoverflow.com/questions/11789407/socket-connections-and-polling-which-is-a-better-solution-in-terms-of-battery-l – karan Aug 03 '15 at 07:53

3 Answers3

0

i think each cab will be fitted with a GPS tracker(could be mobile based app also NOT SURE) to track and send real time data, once the location data changes a TCP connection established will be used to communicate.

Aniruddha K.M
  • 7,361
  • 3
  • 43
  • 52
0

I have the same issue here for my app, where drivers send their locations in a MySQL table in a server.I think the best way to do this is WebSockets, to create a connection between the server and client and send the new location everytime when changed. I really don't know if is the best approach but i will try to do this, maybe can help you also. I'm using PHP so i will try with Ratchet:

Ratchet PHP

Deric Lima
  • 1,972
  • 2
  • 24
  • 33
  • Yes. Socket is one of the best solution to solve this issue. Pooling server is not going to help. – frogEye Feb 09 '16 at 07:00
  • Was the best solution for me until now. I already solved my issue with [Crossbar IO](http://crossbar.io). Crossbar use [WAMP](http://wamp-proto.org) protocol and you can implement RPC or Pub/Sub system. – Deric Lima Feb 09 '16 at 13:15
-1

I think cabs do not communicate to the server or vice versa, until there is some client/passenger who pin his location and destination. The request of client is sent to the server, then server looks for the cab that is closer to the client/passenger. There is quite possibility that they are using GCM Google Cloud Messaging Service of google.

Abad
  • 55
  • 4
  • You need to look into the uber app, I guess. Once you login you can view and see the real time movement of Cabs which are in the area which is displayed in the map on your screen. – frogEye Aug 03 '15 at 07:36