它的好处是只使用GCM开发聊天应用程序为Android开沟XMPP?它的、应用程序、好处、开沟

2023-09-07 23:22:26 作者:旧街里的酒

很多的应用程序,如的WhatsApp 依赖 GCM 将通知发送到设备时,设备处于空闲状态或应用程序在后台运行。在 GCM 消息只是告诉应用程序从服务器同步,然后 XMPP 是用来做实际的聊天(交付有效载荷)。但它是一个很好的决定依靠 GCM 发送消息。所以在我的情况下,当一个用户想要与另一交谈,他送我的服务器的消息,然后我通过 GCM 消息传递到其他用户。我理解 GCM 是不是100%可靠的,但我可以保证通过超时和确认消息的可靠性。还有什么,如果我有完全去与 GCM 可能伤害我。之所以用 XMPP 不会是它会占用大量的努力来缩放 XMPP 服务器(这是我我没有太多熟悉的),但在 GCM 的情况下,我的很多尺度问题被谷歌照顾。

A lot of applications like WhatsApp rely on GCM to send notifications to device when the device is idle or the app is running in background. The GCM message just tells the app to sync from the server and then XMPP is used to do the actual chat(delivering the payload). But is it a good decision to rely on GCM to send messages. So in my case when one user wants to talk with another he sends my server a message and then i deliver the message to the other user through GCM. I understand GCM is not 100% reliable but i can ensure reliability through timeouts and acknowledgement messages. Is there anything else that might hurt me if i go completely with with GCM. The reason for not going with XMPP is that it will take a lot of effort to scale an XMPP server(which i am not much familiar with) but in case of GCM a lot of my scaling issues are taken care of by Google.

推荐答案

我使用GCM提醒客户端连接。如果仅仅依靠GCM提供有效载荷可以不容易跟踪邮件的传递。

I use GCM to alert the client to connect. If you just rely on GCM to deliver the payload you can't track the delivery of messages as easily.

例如我利用流管理的一个非常基本的形式,我的应用程序,所以我preFER随时给只有同步工具,让我的客户机/服务器直接通信。

For example I utilize a very basic form of stream management in my app so I prefer to keep it to a syncing utility only and let my client/server communicate directly.

这也是不可扩展的,虽然你很可能把在邮件正文中的XML和解析。

It is also not extensible, though you could probably put the xml in the message body and parse that.

我不知道交付的保障是什么,但我还检查了在谷歌方面,如果你用它来提供多条消息,你需要确保你纳入 collapse_key的函数到您的客户端,因为GCM将巩固您的信息之一,如果有如果您使用高容量的发送延迟。

I'm not sure what the guarantee on delivery is but I'd also check that out on the google side and if you use it to deliver multiple messages you'll need to make sure you incorporate the collapse_key function into your client because GCM will consolidate your messages into one if there is a delay in sending of if you utilize a high volume.

我不知道在GCM的实时性,所以我不知道这将是一个真正的聊天式的应用程序多么伟大的一件事。

One other thing I'm not sure on the real-timeness of GCM so I'm not sure how great it would be for a real chat-like application.

我想利用GCM有效载荷交付前考虑这些事情。

I'd consider these things before utilizing GCM for the payload delivery.