summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-03-02 16:49:28 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-03-02 16:49:28 +0100
commit4a358f6dfc38132d7c066268dab55f7e4b36a121 (patch)
tree2791187567c7f40071c2d605e9e62278961c1de7
parent431b6f601583e2f07ff4ed02527f7cc83a76e224 (diff)
Add code example.
-rw-r--r--README.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/README.md b/README.md
index 85abb3a..84ddec1 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,31 @@ An incomplete list of implemented and planned features.
* Ability to share variables with other peers. (Implemented, 0.1)
* Network discovery with UDP broadcast. (Implemented, 0.1)
+## Example
+With Same you can share variables easily, like so:
+
+ // First: Some setup to get all your devices connected to the same network.
+ // Then, in your Activity:
+ ClientInterfaceBridge client = new ClientInterfaceBridge(this);
+ client.connect();
+ try {
+ // A VariableFactory is used to create distributed objects.
+ VariableFactory variableFactory = client.createVariableFactory();
+ Variable<String> myVariable = variableFactory.createString("MyVariable");
+
+ // Set the variable.
+ myVariable.set("Hello, Same!");
+
+ // Run update() to get the most recent version.
+ myVariable.update();
+
+ // Get the current value.
+ Log.i("The current value is: " + myVariable.get());
+ } finally {
+ // Always remember to disconnect.
+ client.disconnect();
+ }
+
## Release log
Pre-1.0: A release is a milestone in the project. Whenever the system seems to
be working fairly well, a commit is tagged as the release version.