summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-03-27 10:42:34 +0200
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-03-27 10:42:34 +0200
commite6a2fe124bd1c3c2dc70c4182e4ec4094df95677 (patch)
tree8d13090063b52189a2b3a252adbc4d182c33a151
parenta40161ac665ce982518d8ceea6f6bc6fede10651 (diff)
Change same-android to work with new Same version.
-rw-r--r--same-android/src/main/java/com/orbekk/same/android/SameService.java11
-rw-r--r--same/src/main/java/com/orbekk/same/Master.java4
-rw-r--r--same/src/main/java/com/orbekk/same/SameController.java9
3 files changed, 9 insertions, 15 deletions
diff --git a/same-android/src/main/java/com/orbekk/same/android/SameService.java b/same-android/src/main/java/com/orbekk/same/android/SameService.java
index f2af359..004f5e9 100644
--- a/same-android/src/main/java/com/orbekk/same/android/SameService.java
+++ b/same-android/src/main/java/com/orbekk/same/android/SameService.java
@@ -222,11 +222,10 @@ public class SameService extends Service {
Properties properties = new Properties();
String localIp = new Networking(this)
.getWlanAddress().getHostAddress();
- String localMaster = "http://" + localIp + ":" + SERVICE_PORT +
- "/MasterService.json";
+ String baseUrl = "http://" + localIp + ":" + SERVICE_PORT + "/";
properties.setProperty("port", ""+SERVICE_PORT);
properties.setProperty("localIp", localIp);
- properties.setProperty("masterUrl", localMaster);
+ properties.setProperty("baseUrl", baseUrl);
properties.setProperty("enableDiscovery", "true");
properties.setProperty("discoveryPort", ""+DISCOVERY_PORT);
properties.setProperty("networkName", "AndroidNetwork");
@@ -236,12 +235,12 @@ public class SameService extends Service {
/** Create a public network. */
private void create() {
- sameController.getClient().joinNetwork(
- configuration.get("masterUrl"));
+ sameController.createNetwork(configuration.get("networkName"));
try {
+ // SameController should take care of this.
sameController.getDirectory().registerNetwork(
configuration.get("networkName"),
- configuration.get("masterUrl"));
+ sameController.getMaster().getUrl());
} catch (Exception e) {
Toast.makeText(this, "Unable to register network. " +
"Use manual address to join.",
diff --git a/same/src/main/java/com/orbekk/same/Master.java b/same/src/main/java/com/orbekk/same/Master.java
index ade0b1e..529d729 100644
--- a/same/src/main/java/com/orbekk/same/Master.java
+++ b/same/src/main/java/com/orbekk/same/Master.java
@@ -30,6 +30,10 @@ public class Master {
this.myUrl = myUrl;
}
+ public String getUrl() {
+ return myUrl;
+ }
+
private MasterService serviceImpl = new MasterService() {
@Override
public boolean updateStateRequest(String component,
diff --git a/same/src/main/java/com/orbekk/same/SameController.java b/same/src/main/java/com/orbekk/same/SameController.java
index 95b8c29..8c17807 100644
--- a/same/src/main/java/com/orbekk/same/SameController.java
+++ b/same/src/main/java/com/orbekk/same/SameController.java
@@ -58,31 +58,22 @@ public class SameController {
timeout, timeout);
State clientState = new State(".InvalidClientNetwork");
Broadcaster broadcaster = BroadcasterImpl.getDefaultBroadcastRunner();
-
String baseUrl = String.format("http://%s:%s/",
configuration.get("localIp"), configuration.getInt("port"));
-
- String masterUrl = baseUrl + "MasterService.json";
String clientUrl = baseUrl + "ClientService.json";
MasterServiceProxy master = new MasterServiceProxy();
-// Master master = Master.create(connections, broadcaster,
-// masterUrl, configuration.get("networkName"));
-
Client client = new Client(clientState, connections,
clientUrl, BroadcasterImpl.getDefaultBroadcastRunner());
PaxosServiceImpl paxos = new PaxosServiceImpl("");
-
StateServlet stateServlet = new StateServlet(client.getInterface(),
new VariableFactory(client.getInterface()));
-
ServerContainer server = new JettyServerBuilder(port)
.withServlet(stateServlet, "/_/state")
.withService(client.getService(), ClientService.class)
.withService(master, MasterService.class)
.withService(paxos, PaxosService.class)
.build();
-
SameController controller = new SameController(
configuration, connections, server, master, client,
paxos, broadcaster);