From 671174e17feeacda70cd37b60cb64ca878adf2b3 Mon Sep 17 00:00:00 2001 From: Kevin Jahns <kevin.jahns@rwth-aachen.de> Date: Tue, 19 Aug 2014 21:19:05 +0200 Subject: [PATCH] updated examples --- examples/PeerJs-Json/README.md | 10 ++++++++-- examples/PeerJs-Json/index.js | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/PeerJs-Json/README.md b/examples/PeerJs-Json/README.md index 233aafee..dc3cce8e 100644 --- a/examples/PeerJs-Json/README.md +++ b/examples/PeerJs-Json/README.md @@ -11,6 +11,11 @@ First you have to include the following libraries in your html file: <script src="./index.js"></script> ``` A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js) +### Create Connector + +The PeerJs Framework requires an API key, or you need to set up your own PeerJs server. +Get an API key from the Website. +The first parameter of `createPeerJsConnector` is the options object in PeerJs. ```js @@ -19,13 +24,13 @@ Y.createPeerJsConnector({key: 'h7nlefbgavh1tt9'}, function(Connector, user_id){ ``` +### Yatta yatta is the shared json object. If you change something on this object, it will be instantly shared with all the other collaborators. ```js - yattaHandler = new Y.JsonYatta(user_id, Connector); - yatta = yattaHandler.getSharedObject(); + yatta = new Y.JsonYatta(user_id, Connector); ``` @@ -156,6 +161,7 @@ Apply 'insert' and 'delete' - listeners to Words. ``` +### Experimental method But there is a much more convenient way! diff --git a/examples/PeerJs-Json/index.js b/examples/PeerJs-Json/index.js index bc6e2def..fb64d9c4 100644 --- a/examples/PeerJs-Json/index.js +++ b/examples/PeerJs-Json/index.js @@ -13,15 +13,20 @@ <script src="./index.js"></script> ``` A working widget implementation is [IwcJson.xml](./IwcJson.xml) and the js-file is [index.js](./index.js) +### Create Connector + +The PeerJs Framework requires an API key, or you need to set up your own PeerJs server. +Get an API key from the Website. +The first parameter of `createPeerJsConnector` is the options object in PeerJs. */ var yatta, yattaHandler; Y.createPeerJsConnector({key: 'h7nlefbgavh1tt9'}, function(Connector, user_id){ /** + ### Yatta yatta is the shared json object. If you change something on this object, it will be instantly shared with all the other collaborators. */ - yattaHandler = new Y.JsonYatta(user_id, Connector); - yatta = yattaHandler.getSharedObject(); + yatta = new Y.JsonYatta(user_id, Connector); /** Add a integer-property like this @@ -119,6 +124,7 @@ Y.createPeerJsConnector({key: 'h7nlefbgavh1tt9'}, function(Connector, user_id){ /** + ### Experimental method But there is a much more convenient way! */ console.log(yatta.value.list[2] === 3) // true