Skip to content

Commit

Permalink
Fix Android DNSSD signal 3 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
joonhaengHeo committed Sep 3, 2024
1 parent daa2a57 commit 8c279fa
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
Expand All @@ -45,6 +46,8 @@ public class NsdManagerServiceResolver implements ServiceResolver {
@Nullable private final NsdManagerResolverAvailState nsdManagerResolverAvailState;
private final long timeout;

private ExecutorService mResolveExecutorService;

/**
* @param context application context
* @param nsdManagerResolverAvailState Passing NsdManagerResolverAvailState allows
Expand All @@ -69,6 +72,8 @@ public NsdManagerServiceResolver(

this.nsdManagerResolverAvailState = nsdManagerResolverAvailState;
this.timeout = timeout;

mResolveExecutorService = Executors.newSingleThreadExecutor();
}

public NsdManagerServiceResolver(Context context) {
Expand Down Expand Up @@ -116,7 +121,7 @@ public void run() {
}
};

new Thread(
mResolveExecutorService.execute(
() -> {
if (nsdManagerResolverAvailState != null) {
nsdManagerResolverAvailState.acquireResolver();
Expand All @@ -137,8 +142,7 @@ public void run() {
resolveTimeoutExecutor,
nsdManagerResolverAvailState);
serviceFinderResolver.start();
})
.start();
});
}

@Override
Expand Down

0 comments on commit 8c279fa

Please sign in to comment.