I am toying around with GCM and and am able to register the device and push the message from the server on to the client.
Then I started to wonder if it is possible to push the message to only those clients who are online. Is there any built in mechanism I can use for this or do I need to roll out something of my own.
If I need to roll out my own, are there any other options besides the client <-> server polling at periodic intervals?
I don't think there is a way to determine on your end whether a client is online, or an option to tell GCM to do so. GCM will buffer the message if a client can't be reached right away, and deliver it later (for some value of "later" - messages aren't kept forever).