Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Always send null in generation when peer is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Vabishchevich committed Jan 16, 2017
1 parent fc03971 commit a486bdc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/android/java/io/jxcore/node/JXcoreExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,8 @@ public void notifyPeerAvailabilityChanged(PeerProperties peerProperties, boolean

try {
jsonObject.put(EVENT_VALUE_PEER_ID, peerProperties.getId());
Integer gen = peerProperties.getExtraInformation();
if (!isAvailable) {
gen = (peerProperties.getExtraInformation() == PeerProperties.NO_EXTRA_INFORMATION) ?
null : peerProperties.getExtraInformation();
}
Integer gen = (isAvailable && hasExtraInfo(peerProperties)) ?
peerProperties.getExtraInformation() : null;
jsonObject.put(EVENT_VALUE_PEER_GENERATION, gen);
jsonObject.put(EVENT_VALUE_PEER_AVAILABLE, isAvailable);
jsonObjectCreated = true;
Expand All @@ -570,6 +567,10 @@ public void run() {
}
}

private boolean hasExtraInfo(PeerProperties peerProperties) {
return peerProperties.getExtraInformation() != PeerProperties.NO_EXTRA_INFORMATION;
}

public void notifyDiscoveryAdvertisingStateUpdateNonTcp(boolean isDiscoveryActive, boolean isAdvertisingActive) {
JSONObject jsonObject = new JSONObject();
boolean jsonObjectCreated = false;
Expand Down

0 comments on commit a486bdc

Please sign in to comment.