Skip to content
This repository was archived by the owner on Dec 29, 2019. It is now read-only.

Commit 3050a2d

Browse files
committed
Fixed weird conditions for DNS responders.
1 parent 4711d90 commit 3050a2d

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/main/java/com/peak/salut/Salut.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -683,16 +683,19 @@ public void onDnsSdTxtRecordAvailable(String serviceFullDomainName, Map<String,
683683
if(record.containsValue(thisDevice.serviceName))
684684
{
685685
SalutDevice foundDevice = new SalutDevice(device, record);
686-
687686
foundDevices.add(foundDevice);
688-
if(!firstDeviceAlreadyFound && !callContinously)
687+
688+
if(callContinously)
689689
{
690690
onDeviceFound.call();
691-
firstDeviceAlreadyFound = true;
692691
}
693-
else if(callContinously)
692+
else
694693
{
695-
onDeviceFound.call();
694+
if(!firstDeviceAlreadyFound)
695+
{
696+
onDeviceFound.call();
697+
firstDeviceAlreadyFound = true;
698+
}
696699
}
697700
}
698701
}
@@ -741,14 +744,17 @@ public void onDnsSdTxtRecordAvailable(String serviceFullDomainName, Map<String,
741744
SalutDevice foundDevice = new SalutDevice(device, record);
742745

743746
foundDevices.add(foundDevice);
744-
if(!firstDeviceAlreadyFound && !callContinously)
747+
if(callContinously)
745748
{
746749
onDeviceFound.call(foundDevice);
747-
firstDeviceAlreadyFound = true;
748750
}
749-
else if(callContinously)
751+
else
750752
{
751-
onDeviceFound.call(foundDevice);
753+
if(!firstDeviceAlreadyFound)
754+
{
755+
onDeviceFound.call(foundDevice);
756+
firstDeviceAlreadyFound = true;
757+
}
752758
}
753759
}
754760
}
@@ -900,6 +906,7 @@ public void onSuccess() {
900906
public void stopServiceDiscovery(boolean shouldUnregister)
901907
{
902908
isDiscovering = false;
909+
firstDeviceAlreadyFound = false;
903910

904911
if(isConnectedToAnotherDevice)
905912
disconnectFromDevice();

0 commit comments

Comments
 (0)