Xegara
Xegara

Reputation: 131

How does GCM work in the network layer?

I have read about why it is better to use GCM than having your android app poll continuously for updates from your application server. It is because the android app will only be notified to request an update from its application server when there is really an update - push notifications.

However, I don't see as to how this is possible. How will the server (GCM server) send data to the client (android app) without receiving any request from the client? This violates the client-server architecture that I know of. The only explanation that I can think of is, the GCM-enabled device is actually running its own server that listens to the GCM server. In this network map, the GCM now acts as both the client and the server.

So my question is, is my assumption right? If it is not, then what am I missing?

Upvotes: 0

Views: 812

Answers (3)

Khang .NT
Khang .NT

Reputation: 1589

Google Cloud Message (GCM) only working when android device install "Google Play Service".

This service help android save resources (network bandwidth, battery, ...), how it work:

App 1 |                     | Server 1
App 2 |<--> GCM Service <-->| Server 2
App 3 |                     | Server 3

Instead of:

App 1 |<-->| Server 1
App 2 |<-->| Server 2
App 3 |<-->| Server 3

Your base server send message to Google Cloud and Google play service check message from Google Cloud and send it to you via an intent broashcast

Upvotes: 0

GiapLee
GiapLee

Reputation: 436

1.Android phone connect and keep socket connection to GCM server with a background service which managed by system.

2.Custom server (where you can run database, web service, background module) where will send require (command) to GCM server to push data (notify) to phone (client apps)

Summary: Android phone <-> GCM <-> Custom server (service)

Upvotes: 2

CommonsWare
CommonsWare

Reputation: 1007533

How will the server (GCM server) send data to the client (android app) without receiving any request from the client?

It receives a request from the client. However, that "request" is for a long-lived socket connection, one that is carefully managed to stay up despite the CPU going into sleep mode. If the connection is dropped (e.g., connectivity issues), eventually the client will re-establish the connection.

However, given the open socket, the server can send packets down the socket to the client.

Upvotes: 1

Related Questions