Skip to content

Commit

Permalink
Append commands and remote service ids together during lookup
Browse files Browse the repository at this point in the history
Previously, a `lookupEpoUniqueIdentifiers` call would return either the
list of `remote` service ids (if at least one `remote` service was
available) or the list of `commands` service ids (if no `remote`
services were available). The returned list would not include the
superset of available `remote` and `commands` service ids.

In this commit, the combined list of `remote` and `commands` service ids
is returned for a `lookupEpoUniqueIdentifiers` call.
  • Loading branch information
jbarlow-mcafee committed Aug 29, 2018
1 parent 5e3c3c4 commit 748c097
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions lib/epo-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ function lookupEpoUniqueIdsForServiceType (dxlClient, serviceType,
epoIds.push(epoId)
}
})
epoIds.sort()
}
} catch (err) {
error = err
Expand Down Expand Up @@ -488,20 +487,31 @@ function lookupEpoRemoteServiceUniqueIds (dxlClient, callback) {
* the first parameter supplied to the callback contains an `Error` object
* with failure details. On successful lookup, the array of unique identifier
* strings is provided as the second parameter to the callback and the
* third parameter to the callback is a boolean representing whether the
* ids are for "commands" services (`true`) or "remote" services (`false`).
* third parameter to the callback is a boolean representing whether a
* "commands" (`true`) or a "remote" (`false`) should be used. If at least
* one "remote" service is available, a "remote" service should be used.
* @private
*/
function lookupEpoUniqueIdentifiers (dxlClient, callback) {
lookupEpoRemoteServiceUniqueIds(dxlClient,
function (error, epoIds) {
if (error || !epoIds.length) {
function (error, epoRemoteServiceIds) {
if (epoRemoteServiceIds) {
lookupEpoCommandsServiceUniqueIds(dxlClient,
function (error, epoIds) {
callback(error, epoIds, true)
function (error, epoServiceIds) {
if (epoServiceIds) {
epoRemoteServiceIds.forEach(function (serviceId) {
if (epoServiceIds.indexOf(serviceId) < 0) {
epoServiceIds.push(serviceId)
}
})
epoServiceIds.sort()
callback(error, epoServiceIds, !epoRemoteServiceIds.length)
} else {
callback(error)
}
})
} else {
callback(error, epoIds, false)
callback(error)
}
}
)
Expand Down

0 comments on commit 748c097

Please sign in to comment.