Cosmopolite

Client/server publish/subscribe, presence and key/value storage for AppEngine

Cosmopolite Tutorial

Test cosmopolite

  1. Load the cosmopolite playground debug page.
  2. Subscribe to a subject testsubject
  3. Send a message to that subject; it should appear in the message list at right.

Send a message to a subject

  1. Load the debug page.
  2. Subscribe to testsubject
  3. Load tutorial page #1
  4. Click Execute JavaScript, then click OK on the popup
  5. The debug page should show the message from the tutorial page

Subscribe to a subject

  1. Load tutorial page #2
  2. Click Execute JavaScript, then click OK on the popup
  3. Use the debug page to send a message to testsubject
  4. The tutorial page should generate an alert popup

Key/value store

  1. Cosmopolite can be used as a key/value store, with historical data and update notification
  2. When subscribing to a subject, you can request the most recent message for that subject
  3. Load tutorial page #3
  4. Click Execute JavaScript, then click OK on the popup
  5. The tutorial page should generate an alert popup showing the last message sent

Pin a value

  1. Pins publish a message temporarily, until the source conncetion disconnects. This can be used for presence information
  2. Load the debug page.
  3. Subscribe to testsubject
  4. Load tutorial page #4
  5. Click Execute JavaScript, then click OK on the popup
  6. Watch the debug page; you should see the pin.
  7. Close tutorial page #4; the pin disappears from the debug page.

Set up a local instance for further testing

  1. Download and install the Python AppEngine SDK
  2. Create an application in your SDK client
  3. Download cosmopolite via the links at left. Unpack it into your local application directory and rename the newly-created subdirectory to "cosmopolite"
  4. Create an app.yaml file for your application.
  5. Add a cosmopolite include to your app.yaml file:
    includes:
    - cosmopolite
    
    inbound_services:
    - channel_presence
  6. Start the application in your SDK client
  7. Create a test.html page at the top level of your application:
    <html>
      <head>
        <script src="/cosmopolite/static/cosmopolite.js" charset="UTF-8"></script>
      </head>
      <body>
        <script>
    // Subsequent script examples go here
        </script>
      </body>
    </html>
  8. Add a mapping to app.yaml:
    handlers:
    - url: /test.html
      static_files: test.html
      upload: test.html
  9. Remove the mapping for main.app from app.yaml (if using the autogenerated file)
  10. Retry the examples above using your new test page and your local debug page