Alin miu google app engine(gae) v1.1


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Alin miu google app engine(gae) v1.1

  1. 1. Google App EngineReal-time communication using Channel API
  2. 2. What Is Google App Engine(GAE)?• Google App Engine lets you run web applications on Googles infrastructure.• With App Engine, there are no servers to maintain: you just upload your application, and its ready to serve your users.• Google App Engine applications can currently be written in Java, Python, or Go.
  3. 3. Push and Pull• Pull: – AJAX• Push: – WebSockets
  4. 4. Channel API(Push)• Creates a persistent connection between your application and Google servers• Allows your application to send messages to JavaScript clients in real time without the use of polling.
  5. 5. Channel API(Push)Javascript Client: – Connecting to the channel once it receives the channel’s unique token from the server – Listening on the channel for updates – Sending update messages to the serverThe Server: – Creating a unique channel for individual JavaScript clients – Creating and sending a unique token to each JavaScript client so they may connect and listen to their channel – Receiving update messages from clients via HTTP requests – Sending update messages to clients via their channels – Optionally, managing client connection state.
  6. 6. Channel API(Push)The Client ID: – The Client ID is responsible for identifying individual JavaScript clients on the server. – A Client ID can be anything that makes sense in the design of your application.Tokens: – Tokens are responsible for allowing the JavaScript Client to connect and listen to the channel created for it. – The server creates one token for each client using information such as the client’s Client ID and expiration time. – Tokens expire after two hours and should also be treated as secret.
  7. 7. Channel API(Push)The Channel – A channel is a one-way communication path through which the server sends updates to a specific JavaScript client identified by its Client ID. – The server receives updates from clients via HTTP requests, then sends the messages to relevant clients via their channels.The Message – Messages are sent via HTTP requests from one client to the server. – Once received, the server passes the message to the designated client via the correct channel identified by the Client ID. – Messages are limited to 32K.
  8. 8. Channel API(Push)
  9. 9. Channel API(Push)
  10. 10. Channel API(Push)<body> <script> channel = new goog.appengine.Channel({{ token }}); socket =; socket.onopen = onOpened; socket.onmessage = onMessage; socket.onerror = onError; socket.onclose = onClose; </script></body> sendMessage = function(path) { path += ?g= + message; var xhr = new XMLHttpRequest();, path, true); xhr.send(); };
  11. 11. Demo: