From 4a358f6dfc38132d7c066268dab55f7e4b36a121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Fri, 2 Mar 2012 16:49:28 +0100 Subject: Add code example. --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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 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. -- cgit v1.2.3