Google Cloud Messaging - CCS (XMPP) vs HTTP server

2020-02-25 05:08发布

I've read the documentation https://developer.android.com/google/gcm/index.html

and the only difference I can see is that a CCS (XMPP) based server allows bi-directional communication directly between an android device and the GCM server.

Are there any other reasons why you would choose CCS (XMPP) over HTTP or vice versa?

5条回答
姐就是有狂的资本
2楼-- · 2020-02-25 05:27

XMPP messaging differs from HTTP messaging in the following ways:

Upstream/Downstream messages

  • HTTP: Downstream only, cloud-to-device.
  • XMPP: Upstream and downstream (device-to-cloud, cloud-to-device).

Messaging (synchronous or asynchronous)

  • HTTP: Synchronous. App servers send messages as HTTP POST requests and wait for a response. This mechanism is synchronous and blocks the sender from sending another message until the response is received.
  • XMPP: Asynchronous. App servers send/receive messages to/from all their devices at full line speed over persistent XMPP connections. The XMPP connection server sends acknowledgment or failure notifications (in the form of special ACK and NACK JSON-encoded XMPP messages) asynchronously.

JSON

  • HTTP: JSON messages sent as HTTP POST.
  • XMPP: JSON messages encapsulated in XMPP messages.

Plain Text

  • HTTP: Plain Text messages sent as HTTP POST.
  • XMPP: Not supported.

Multicast downstream send to multiple registration tokens.

  • HTTP: Supported in JSON message format.
  • XMPP: Not supported.
查看更多
叛逆
3楼-- · 2020-02-25 05:31

You can broadcast a message to 1000 devices at a time with a single http call to gcm. For broadcasting http is better than CCS.

查看更多
Rolldiameter
4楼-- · 2020-02-25 05:36

From Google docs :

You can continue to use the HTTP request mechanism to send messages to GCM servers, side-by-side with CCS which uses XMPP. Some of the benefits of CCS include:

The asynchronous nature of XMPP allows you to send more messages with fewer resources.

Communication is bidirectional—not only can your server send messages to the device, but the device can send messages back to your server.

The device can send messages back using the same connection used for receiving, thereby improving battery life.

查看更多
欢心
5楼-- · 2020-02-25 05:44

CCS (XMPP) is asynchronous, which means it should be faster than HTTP. It also uses the existing GCM connection on the device to send messages from your app to your server (which saves battery, since you don't have to open your own connection to your server).

On the other hand, HTTP is much simpler to code, so unless you need the bi-directional functionality or you need to send messages in a very high speed, I'd stick with HTTP.

查看更多
男人必须洒脱
6楼-- · 2020-02-25 05:44

unfortunately google cloud platform will disable the XMPP API after a year https://cloud.google.com/appengine/docs/deprecations/xmpp

I'd choose XMPP to save devices battery cause its one of the big concern nowadays!

查看更多
登录 后发表回答