移动应用程序,针对Web服务的短期轮询与长期轮询

时间:2018-09-26 18:19:17

标签: php android mysql unity3d

搜索几天后,我需要与您确认。我正在制作一个Android应用程序和一个Unity 3D手机游戏。我正在添加功能,例如在应用程序中传递消息,朋友和成就。我在服务器端使用PHP和Mysql。对于诸如添加好友,发送消息,检查新消息之类的每项操作,我都使用单个PHP文件。流程是:

APP send POST data, 
PHP process query , 
Mysql delivers info to php,
PHP delivers info, 
APP uses that info.
Repeat every 3-5 seconds to simulate real time.

为什么我应该使用长时间轮询?我知道伪代码应该是:

APP send POST data, 
PHP process query , 
if there is new info
Mysql delivers info to php,
PHP delivers info,
else wait 2-3s and then goto "PHP process query". 
APP uses that info.

我只使用PHP和Mysql,因为我认为使用经典的虚拟主机将既便宜又便宜。我应该使用长轮询还是短轮询?

还是应该使用现有服务?哪一个?火力基地? Google Cloud? AWS?天蓝色?谢谢你的时间。我不知道该使用哪本书籍或参考资料。

0 个答案:

没有答案