Skip to content

Commit

Permalink
Fix Android resolve exception issue
Browse files Browse the repository at this point in the history
  • Loading branch information
joonhaengHeo committed Sep 12, 2024
1 parent 7249c56 commit ccddb8c
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class NsdServiceFinderAndResolver implements NsdManager.DiscoveryListener {
private final ChipMdnsCallback chipMdnsCallback;
private final MulticastLock multicastLock;
private final ScheduledFuture<?> resolveTimeoutExecutor;
private NsdServiceInfo discoveredServiceInfo = null;

@Nullable
private final NsdManagerServiceResolver.NsdManagerResolverAvailState nsdManagerResolverAvailState;
Expand Down Expand Up @@ -94,14 +95,13 @@ public void run() {

@Override
public void onServiceFound(NsdServiceInfo service) {
if (targetServiceInfo.getServiceName().equals(service.getServiceName())) {
if (discoveredServiceInfo == null && targetServiceInfo.getServiceName().equals(service.getServiceName())) {
Log.d(TAG, "onServiceFound: found target service " + service);

if (stopDiscoveryRunnable.cancel(false)) {
nsdManager.stopServiceDiscovery(this);
}

resolveService(service, callbackHandle, contextHandle, chipMdnsCallback);
discoveredServiceInfo = service;
} else {
Log.d(TAG, "onServiceFound: found service not a target for resolution, ignoring " + service);
}
Expand Down Expand Up @@ -206,7 +206,10 @@ public void onServiceLost(NsdServiceInfo service) {

@Override
public void onDiscoveryStopped(String serviceType) {
Log.i(TAG, "Discovery stopped: " + serviceType);
Log.i(TAG, "Discovery stopped: " + serviceType + ", discoveredServiceInfo: " + discoveredServiceInfo);
if (discoveredServiceInfo != null) {
resolveService(discoveredServiceInfo, callbackHandle, contextHandle, chipMdnsCallback);
}
}

@Override
Expand Down

0 comments on commit ccddb8c

Please sign in to comment.