Giter Club home page Giter Club logo

gcm_server's Introduction

Readme

This is a sample project to showcase Google Cloud Messaging using upstream messaging. This project is a very simply standalone server. Though that's not part of this sample I was able to utilize this project from within a Java webapp.

The project was originally created for a talk I held at the Dutch Android User Group meeting in Utrecht on January, 16th 2014. If you ever have the possibility to visit a meeting of the Dutch AUG, I stringly recommend to do so. It has been a gorgeous evening!

Libraries used

This project makes use of Smack and Json-simple. The code is based on a sample class provided by Google on the XMPP documentation page.

Most important classes

All classes are within the com.grokkingandroid.sampleapp.samples.gcm.ccs.server package.

CcsClient contains a main method which takes three arguments:

  1. The project number
  2. The API key
  3. A registration id to send a test message to

If you start it that way, the GUI of the Smack library is used to show incoming and outgoing messages.

Of course, you also can use CcsClient from within any other project. In my case I used it from within a web project to send messages to the Android client.

In that case you first have to call prepareClient() and pass it the project number and the api key as arguments. The third argument decides whether the GUI should be shown or not. On servers you have to set this to false.

The registration ids of the Android clients and all message are stored in memory. This is managed by the PseudoDao class. This should help you to get started with a real persistence solution for production.

For this sample all incoming messages must follow a certain format. That is, they must contain at least an action key with a supported value. This action key determines which PayloadProcessor to create. The implementations of PayloadProcessor (EchoProcessor, MessageProcessor and RegisterProcessor) finally handle the incoming messages and perform the appropriate actions.

Credentials

To run this project you need a GCM-project number and an API key. You can read more about it on the Getting Started page of Google's documentation.

Those are passed into the CcsClient by either calling the prepareClient() method or by providing those as arguments to the main method.

Keep in mind: For using Google Cloud Messaging with XMPP you need to apply first. See for example the note at the top of the [http://developer.android.com/google/gcm/notifications.html](User Notification page). You can find a current link there as well.

Relevant Blogposts on Grokking Android

Right now I haven't finished the blog post about GCM. It's in the making and should be up pretty soon.

Developed by

Wolfram Rittmeyer - You can contact me via:

Thanks

A big thanks to the organizers of the meetup in Utrecht. It was a great evening with good presentations and interesting conversations in the breaks!

Also thanks to all my readers and blog commenters. Your feedback helps me to stay on track and to go on with projects like this. Without my blog (and thus you) I probably woouln't have been invited in the first place :-)

Special thanks also to the Android crowd on G+. You're an awesome crowd. I have gained many insights by reading posts there, by following links to blog posts or by discussions on G+! And it was great to meet some of you in Utrecht.

And finally: This readme was created using dillinger.io. Thanks for this service.

License

Copyright 2014 Wolfram Rittmeyer

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

gcm_server's People

Contributors

writtmeyer avatar abrad1212 avatar rohanag12 avatar

Stargazers

cleverpig avatar Michael Ferguson avatar DenisKa avatar  avatar  avatar Mike avatar Andy Boothe avatar Samuele avatar Christian Schneppe avatar Christian K. Kaderud avatar  avatar Ali Shahbour avatar Noel Trivedi avatar Tapshil Desai avatar Omar Alejandro Mainegra Sarduy avatar Ben avatar Stanislav Nedelko avatar Dmitriy Che avatar Amy Nagle avatar Pandiyaraja Ramamoorthy avatar  avatar Anudeep Samaiya avatar Evan Jarrett avatar Matt McKenna avatar Lapshin Dmitry avatar shinjjang avatar iroïd avatar Aaron Nwabuoku avatar Nitin Sharma avatar junior kabore avatar Brad Armstrong avatar Ronny avatar Michal Pavlasek avatar Tim Spann avatar Daniel Iñigo avatar Petr Moravek avatar Joan Pujol avatar Shiaupiau avatar Wade avatar  avatar  avatar KARTHIKEYAN PALANISAMY avatar Francisco A. Lozano avatar ccadete avatar Lovell Felix avatar  avatar

Watchers

Neustradamus avatar kenji yoshida avatar  avatar KARTHIKEYAN PALANISAMY avatar Eric Chow avatar  avatar  avatar  avatar  avatar Amartya Sarkar avatar Attila Gergely avatar

gcm_server's Issues

Keeping connection alive

When the debugger is set to false for server purpose, the program exits after some idle time, how to keep the server running. Do i have to implement ping pong mechanism of smack. If the debugger is true the program waits indefinitely.

upload to server

how to deploy this project in my personal server ?? what i need to do

thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.