summaryrefslogtreecommitdiff
path: root/same/src/main
diff options
context:
space:
mode:
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);
+ }
+ }
+ }
}