简体   繁体   English

Android App中的实时跟踪

[英]Real Time Tracking in Android App

How does app like Uber do real time tracking of Cabs? 像Uber这样的应用程序如何对出租车进行实时跟踪? 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: 我浏览了许多博客,之后我可以想到以下解决2个问题的解决方案:

  1. Cabs will communicate there lat/long to server after some time gap using http request. 间隔一段时间后,出租车将使用http请求与服务器进行纬度/经度通信。
  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. 请提供您对该问题的见解。

我认为每辆出租车都将装有GPS跟踪器(也可以是基于移动的应用程序,但也不能肯定),以跟踪和发送实时数据,一旦位置数据发生更改,建立的TCP连接将用于通信。

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. 我的应用程序存在相同的问题,驱动程序在服务器的MySQL表中发送其位置,我认为最好的方法是WebSockets,在服务器和客户端之间建立连接并在每次发送新位置时发送新位置改变了。 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: 我正在使用PHP,所以我将尝试使用Ratchet:

Ratchet PHP 棘轮PHP

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. 他们很有可能正在使用Google的GCM Google Cloud Messaging Service。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM