summaryrefslogtreecommitdiff
path: root/same/src/main
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-27 14:03:54 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-27 14:03:54 +0100
commitf1be615e30f4a6832bd0b805e155c0775b624964 (patch)
tree3c1edc9b91e5bb0f43fcdb2bce93790cf4f9fd2d /same/src/main
parent3d0ddd70342bee8826997e9a2343a5741e243a0d (diff)
Client answers discovery events.
Diffstat (limited to 'same/src/main')
-rw-r--r--same/src/main/java/com/orbekk/same/ClientServiceImpl.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/same/src/main/java/com/orbekk/same/ClientServiceImpl.java b/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
index 8aaaa95..b46dbfb 100644
--- a/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
+++ b/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
@@ -4,7 +4,8 @@ import org.codehaus.jackson.type.TypeReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ClientServiceImpl implements ClientService, UrlReceiver {
+public class ClientServiceImpl implements ClientService, UrlReceiver,
+ DiscoveryListener {
private Logger logger = LoggerFactory.getLogger(getClass());
private ConnectionManager connections;
private State state;
@@ -104,4 +105,17 @@ public class ClientServiceImpl implements ClientService, UrlReceiver {
public void setNetworkListener(NetworkNotificationListener listener) {
this.networkListener = listener;
}
+
+ @Override
+ public void discover(String url) {
+ if (!url.equals(myUrl)) {
+ try {
+ connections.getClient(url + "/ClientService.json")
+ .notifyNetwork(state.getDataOf(".networkName"),
+ state.getDataOf(".masterUrl"));
+ } catch (Exception e) {
+ logger.warn("Failed to contact new client {}", url, e);
+ }
+ }
+ }
}