Git Product home page Git Product logo

channel-map-demo's Introduction

Demo: Google App Engine Channel API with Google Maps

This is a demo showing how to send updates to multiple connected clients using the Google App Engine Channel API. The messages are used to display a product on a Google Map.

The weakness of the implementation is that there is a race condition with adding or removing clients to the JSON object in memcache. However, it works as a simple demo.

This code was extracted from the BBYScan map which displays live QR code scans from Best Buy stores. For more details about the BBYScan project, read our blog post.

For the demo, scans are simulated from a few sample products and stores.

Using the Demo

This demo requires the Google App Engine SDK.

  1. Check out the code and cd into that directory
  2. Start your local server: dev_appserver.py .
  3. Visit the map page at http://localhost:8080/
  4. In another tab, launch the mock scan submission service at http://localhost:8080/scan
  5. Watch the simulated scans come in.

You can open the map in multiple web browsers to see the channel API push the same updates to multiple clients.

Since channels can only stay open for 2 hours, it is necessary to periodically re-establish a new channel connection. This is accomplished by sending a 'refresh' JSON message to the client. In this demo, that causes the page to reload, which is the simplest way to re-establish a channel. This is accomplished with a cron.yaml entry that runs once an hour.

To demo this behavior, the channel refresh timeout has been set very low, to one minute. Since cron does not run in the SDK, you must trigger it manually. Do this by visiting http://localhost:8080/cleanup in another window. If your web browser has been on the map page for more than one minute, it will refresh.

License

This code is copyright Best Buy and licensed under the AGPL. See LICENSE.txt for details.

channel-map-demo's People

Contributors

look avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.