Implement Basic WebSocket support
Extracted three methods in order to improve readability.
Add some debug messages in registerAtGcm
some code formatting