-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempt fixing issues with jmdns #107
- Loading branch information
khk624
authored and
khk624
committed
Jun 16, 2014
1 parent
60ffc89
commit 1f5cd42
Showing
4 changed files
with
36 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
package com.connectsdk.discovery.provider; | ||
|
||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Timer; | ||
|
@@ -31,6 +32,7 @@ | |
import javax.jmdns.JmDNS; | ||
import javax.jmdns.ServiceEvent; | ||
import javax.jmdns.ServiceListener; | ||
import javax.jmdns.ServiceTypeListener; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
@@ -45,6 +47,8 @@ | |
import com.connectsdk.service.config.ServiceDescription; | ||
|
||
public class ZeroconfDiscoveryProvider implements DiscoveryProvider { | ||
private static final String HOSTNAME = "connectsdk"; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
iheart2code
Contributor
|
||
|
||
JmDNS jmdns; | ||
|
||
private final static int RESCAN_INTERVAL = 10000; | ||
|
@@ -116,20 +120,24 @@ public void serviceAdded(ServiceEvent event) { | |
private CopyOnWriteArrayList<DiscoveryProviderListener> serviceListeners; | ||
|
||
public ZeroconfDiscoveryProvider(Context context) { | ||
initJmDNS(); | ||
initJmDNS(context); | ||
|
||
services = new ConcurrentHashMap<String, ServiceDescription>(8, 0.75f, 2); | ||
serviceListeners = new CopyOnWriteArrayList<DiscoveryProviderListener>(); | ||
serviceFilters = new ArrayList<JSONObject>(); | ||
} | ||
|
||
private void initJmDNS() { | ||
private void initJmDNS(final Context context) { | ||
Util.runInBackground(new Runnable() { | ||
|
||
@Override | ||
public void run() { | ||
try { | ||
jmdns = JmDNS.create(); | ||
InetAddress source = Util.getIpAddress(context); | ||
if (source == null) | ||
return; | ||
|
||
jmdns = JmDNS.create(source, HOSTNAME); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
|
@khk624 Why are you generating a static value for the hostname? Isn't this supposed to come from the device somewhere?