diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-03-20 15:54:17 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-03-20 15:54:17 +0100 |
commit | 810c7c1587b5c44c150eb4ba893874555802fc6b (patch) | |
tree | 8b34c6ca117d489241b66def1a394f26dcea2a14 /same/src/main/java/com/orbekk/same/discovery/DiscoveryService.java | |
parent | a16f9ef4b751900a412da4c72c9245f716dc29a6 (diff) |
Remove discovery code.
Use centralized discovery instead.
Diffstat (limited to 'same/src/main/java/com/orbekk/same/discovery/DiscoveryService.java')
-rw-r--r-- | same/src/main/java/com/orbekk/same/discovery/DiscoveryService.java | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/same/src/main/java/com/orbekk/same/discovery/DiscoveryService.java b/same/src/main/java/com/orbekk/same/discovery/DiscoveryService.java deleted file mode 100644 index a1147cc..0000000 --- a/same/src/main/java/com/orbekk/same/discovery/DiscoveryService.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.orbekk.same.discovery; - -import java.net.DatagramPacket; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.orbekk.net.BroadcastListener; - -public class DiscoveryService extends Thread { - private Logger logger = LoggerFactory.getLogger(getClass()); - BroadcastListener broadcastListener; - DiscoveryListener listener; - - public DiscoveryService(DiscoveryListener listener, - BroadcastListener broadcastListener) { - this.listener = listener; - this.broadcastListener = broadcastListener; - } - - @Override - public void run() { - logger.info("DiscoveryService starting."); - while (!Thread.interrupted()) { - DatagramPacket packet = broadcastListener.listen(); - if (packet == null) { - // An error or interrupt occurred. - continue; - } - String content = new String(packet.getData(), 0, packet.getLength()); - String[] words = content.split(" "); - - if (!content.startsWith("Discover") || words.length < 2) { - logger.warn("Invalid discovery message: {}", content); - continue; - } - - String url = words[1]; - logger.info("Received discovery from {}", url); - if (listener != null) { - listener.discover(url); - } - } - logger.info("DiscoveryService stopped."); - } - - @Override public void interrupt() { - logger.info("Interrupt()"); - super.interrupt(); - broadcastListener.interrupt(); - } -} |