Suggested tutorial cleanups
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
|
||||
<ol>
|
||||
<li>Create an application in your SDK client</li>
|
||||
<li>Download cosmopolite via the links at left. Unpack it into a "cosmopolite" subdirectory of your local application</li>
|
||||
<li>Download cosmopolite via the links at left. Unpack it into your local application directory and rename the newly-created subdirectory to "cosmopolite"</li>
|
||||
<li>Create an <a href="https://developers.google.com/appengine/docs/python/config/appconfig">app.yaml</a> file for your application.</li>
|
||||
<li>Add a cosmopolite include to your app.yaml file:
|
||||
<pre>includes:
|
||||
@@ -72,10 +72,11 @@
|
||||
- url: /test.html
|
||||
static_files: test.html
|
||||
upload: test.html</pre></li>
|
||||
<li>Have it create a cosmopolite instance and send a message to it:
|
||||
<li>Remove the mapping for main.app from app.yaml (if using the autogenerated file)</li>
|
||||
<li>Edit test.html. Replace "// Subsequent script examples go here" with:
|
||||
<pre>var cosmo = new Cosmopolite();
|
||||
cosmo.sendMessage('testsubject', 'test message');</pre></li>
|
||||
<li>Keep the debug page (from above) up and subscribed (to <i>testsubject</i>) in one browser tab</li>
|
||||
<li>Keep the <a href="http://localhost:8080/cosmopolite/static/debug.html" target="_blank">debug page</a> up and subscribed (to <i>testsubject</i>) in one browser tab</li>
|
||||
<li>Load <a href="http://localhost:8080/test.html" target="_blank">your test page</a></li>
|
||||
<li>The debug page should show the message from the test page</li>
|
||||
<li>You've written code that uses cosmopolite!</li>
|
||||
@@ -95,7 +96,7 @@ cosmo.sendMessage('testsubject', 'test message');</pre></li>
|
||||
<h3>Subscribe to a subject</h3>
|
||||
|
||||
<ol>
|
||||
<li>Change your test script:
|
||||
<li>Change test.html:
|
||||
<pre>var callbacks = {
|
||||
onMessage: function(msg) {
|
||||
alert(msg['message']);
|
||||
@@ -103,7 +104,7 @@ cosmo.sendMessage('testsubject', 'test message');</pre></li>
|
||||
};
|
||||
var cosmo = new Cosmopolite(callbacks);
|
||||
cosmo.subscribe('testsubject');</pre></li>
|
||||
<li>Load (or re-load) the test page</li>
|
||||
<li>Load (or re-load) the <a href="http://localhost:8080/test.html" target="_blank">test page</a></li>
|
||||
<li>Use the debug interface to send a message to <i>testsubject</i></li>
|
||||
<li>Your test page should generate an alert popup</li>
|
||||
</ol>
|
||||
@@ -113,7 +114,7 @@ cosmo.subscribe('testsubject');</pre></li>
|
||||
<ol>
|
||||
<li>Cosmopolite can be used as a key/value store, with historical data and update notification</li>
|
||||
<li>When subscribing to a subject, you can request the most recent message for that subject</li>
|
||||
<li>Change your test script:
|
||||
<li>Change test.html:
|
||||
<pre>var cosmo = new Cosmopolite();
|
||||
cosmo.subscribe('testsubject', 1).then(function() {
|
||||
var msg = cosmo.getLastMessage('testsubject');
|
||||
@@ -127,10 +128,10 @@ cosmo.subscribe('testsubject', 1).then(function() {
|
||||
<ol>
|
||||
<li>Pins publish a message temporarily, until the source conncetion disconnects. This can be used for presence information</li>
|
||||
<li>Open the debug interface and subscribe to <i>testsubject</i></li>
|
||||
<li>Change your test script:
|
||||
<li>Change test.html:
|
||||
<pre>var cosmo = new Cosmopolite();
|
||||
cosmo.pin('testsubject', 'browser is alive!');</pre></li>
|
||||
<li>Load the test page and watch the debug page; you should see the pin.</li>
|
||||
<li>Load the <a href="http://localhost:8080/test.html" target="_blank">test page</a> and watch the debug page; you should see the pin.</li>
|
||||
<li>Close the test page, and the pin disappears.</li>
|
||||
</ol>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user