gpt4 book ai didi

php - Android XMPP - 服务器端

转载 作者:太空宇宙 更新时间:2023-11-03 12:16:13 25 4
gpt4 key购买 nike

我尝试学习 Android 和网络服务器之间的实时通信。通信应该与 XMPP 和 GCM 一起工作。现在我需要服务器端的帮助。服务器端的推送通知应该使用什么?什么性能最好?我考虑将 PHP 与 GCM 结合使用。或者有更好的选择吗?数据应存储在 MYSQL 数据库中的网络服务器上。我已经搜索过了,但是有很多不同的解决方案,所以很困惑。

最佳答案

Google Cloud Messaging现在是向运行应用程序的应用程序发送消息的首选方法,因为 Cloud to Device Messaging 已贬值.

正如您提到的,有 XMPP以及这恰好是我目前最喜欢的。

它功能强大、功能齐全、可扩展,如果您想在自己的机器上托管它,甚至可以使用开源解决方案。如果你这样做,我推荐OpenFire .

为了满足胃口,这里有一些使用 XMPP 的电池生命周期基准:

The Android client must maintain a persistent TCP connection by waking up periodically to send a heartbeat to the XMPP server. This clearly imposes a cost in terms of power usage. An estimate of this cost is provided below:

  • Using a 1400mAh battery (as supplied in the Nexus and HTC)
  • An idle device, connected to an 3G network, uses approximately 5mA
  • The wake-up, heartbeat, sleep cycle occurs every 5 minutes, takes three seconds to complete and uses 300mA

The cost in battery usage per hour is therefore:

  • 36 seconds 300mA = 3mAh sending heartbeat
  • 3600 seconds 5mA = 5mAh at idle
  • 4:95 + 3 = 7:95mAh combined
  • A 1400mAh battery lasts approximately 11.6 days at idle and 7.3 days when running the application, which represents an approximate 37% reduction in battery life.
  • However, a reduction in battery life of 37% represents the absolute worst case in practice given that devices are rarely completely idle.

关于php - Android XMPP - 服务器端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22026784/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com