本文介绍了PubNub 与 PHP 服务器和 Android 应用程序的集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我必须使用 Android 应用程序定期(例如 30 秒)将用户的位置发送到服务器,PHP 服务器返回最近的用户,应用程序将他们显示在地图上.我正在寻找用于实时数据传输的发布订阅协议.

In my project I have to send user's location periodically (E.g. 30Sec) to server using Android application and the PHP server returns nearest users and app displays them on the map. I am looking for a publish subscribe protocol for the real time data transfer.

这是我计划的架构.每个移动应用程序用户 ID 将被视为一个主题或频道,以便我们可以向每个用户发送响应.PHP 服务器将被视为一个主题,例如APP_SERVER_TRACKER".所有移动应用程序都将位置发布到服务器主题.服务器准备列表并通过使用他们的 id 作为主题向单个用户发布响应.

Here is the architecture I was planned. Each mobile app users id will be considered as a topic or channel so that we can send response to each user. PHP server will considered as a topic e.g. "APP_SERVER_TRACKER". All mobile apps publishes location to Server topic. Server prepares the list and publish response to individual user's by using their id as topics.

我想知道我的 PHP 后端服务器如何订阅主题?实际上,我的所有用户都通过 PubNub 使用单个通道连接到我的 PHP 后端服务器.获取每个用户服务器的位置后,对其进行处理并向最终用户发布响应.在这种情况下,我需要扩展我的 PHP 服务器吗?有没有办法在 PHP 服务器本身内直接处理我的所有客户请求?请指教?

I would like to know how my PHP Backend Server subscribe topic?In reality all my users are connecting to my PHP Backend Server using a single channel via PubNub. After getting location of each user server process it and publishes response to end user. In this scenario do I need to scale my PHP Server? Is there a way for directly handling all my customer request within the PHP Server itself? Please advice?

该应用将面向至少 1000 万用户.应该支持一半的并发用户.PHP 服务器托管将在 AWS EC2 m3.2xlarge 8 核心实例中.请告诉我 AWS 服务器配置是否足够?

The application will target at least 10 Million users. should support half of concurrent users. PHP Server Hosting will be in AWS EC2 m3.2xlarge 8 core instance. Please let me know if AWS Server configuration is adequate?

推荐答案

PubNub Geohash 用例

您不需要 PHP 服务器来执行此操作.只需让您的 Android 应用订阅到一个称为地理散列频道(基于您的位置的频道名称)的频道.您的应用还将发布它的位置到该频道.

PubNub Geohash Use Case

You don't need your PHP server to do this. Just have your Android app subscribe to a channel that is what is call a geo-hashed channel (a channel name based on your location). Your app will also publish its location to that channel.

因此,现在您从附近的其他人处接收位置更新,同时将您的位置发送给附近您的人.

So now you are receiving location updates from others near you while at the same time you are sending your location to those that are near you.

有关详细信息,请参阅 PubNub Geohash 用例.

See PubNub Geohash use cases for more details.

这篇关于PubNub 与 PHP 服务器和 Android 应用程序的集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 19:18