@@ -0,0 +1,1350 @@
+package com.orbekk.same;%0A%0Aimport java.net.DatagramPacket;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport com.orbekk.net.BroadcastListener;%0A%0Apublic class DiscoveryService extends Thread %7B%0A    private Logger logger = LoggerFactory.getLogger(getClass());%0A    BroadcastListener broadcastListener;%0A    DiscoveryListener listener;%0A    %0A    public DiscoveryService(int port, DiscoveryListener listener,%0A            BroadcastListener broadcastListener) %7B%0A        this.listener = listener;%0A        this.broadcastListener = broadcastListener;%0A    %7D%0A    %0A    public void run() %7B%0A        while (!Thread.interrupted()) %7B%0A            DatagramPacket packet = broadcastListener.listen();%0A            String content = new String(packet.getData(), 0, packet.getLength());%0A            String%5B%5D words = content.split(%22 %22);%0A            %0A            if (!content.startsWith(%22Discover%22) %7C%7C words.length %3C 2) %7B%0A                logger.warn(%22Invalid discovery message: %7B%7D%22, content);%0A                continue;%0A            %7D%0A            %0A            String url = words%5B1%5D;%0A            logger.info(%22Received discovery from %7B%7D%22, url);%0A            if (listener != null) %7B%0A                listener.discover(url);%0A            %7D%0A        %7D%0A    %7D%0A    %0A    @Override public void interrupt() %7B%0A        super.interrupt();%0A        broadcastListener.interrupt();%0A    %7D%0A%7D%0A

Add DiscoveryService.