Android GCM : understanding XMPP

后端 未结 1 1840
一向
一向 2021-01-07 06:38

I\'m trying to implement a XMPP protocol in my GCM using app, but even after searching extensively, I don\'t understand the concepts behind it.

Also, maybe I don\'t r

相关标签:
1条回答
  • 2021-01-07 07:12

    Official definition:

    The Google Cloud Messaging (GCM) Cloud Connection Server (CCS) is an XMPP endpoint that provides a persistent, asynchronous, bidirectional connection to Google servers.

    Establishing a connection with CCS is the first and most important step here. Once you are done with this and maintain a long-lived connection, other parts are not that tricky.

    Some differences between the two:
    1) Unlike HTTP, with XMPP messages you do not need to include Authentication headers with every payload since server is authenticated at the time of connecting and we are maintaining the same connection.
    2) CCS uses XMPP as a Transport Layer and therefore after you have successfully established connection you can exchange stanzas.
    3) You could keep using HTTP for downstream though and use XMPP only for upstream if you wish.
    4) Instead of registration_ids param use to: in XMPP and we can only send to one RegID through one stanza.

    So if I were to explain how your example would work with XMPP:
    - Establish a connection with CCS
    - Send an upstream message to your server from the client "Hello, World!"
    - Acknowledge once your server receives this message by sending ACK to GCM
    - For downstream message you have choice of using either of HTTP or XMPP
    - But if XMPP: receive, save in database and when sending response ({"myResponse":"I'm not world I'm Dan"}) back to the client (same or different RegID) send a downstream stanza to CCS; CCS will send ACK/NACK to acknowledge that it has received the message
    - You will also receive delivery_receipt (if requested) once the client app has received the message.

    Other than this, you can understand more in depth by reading the official documentation which I have linked throughout the post.

    Hope this helps!

    0 讨论(0)
提交回复
热议问题