errorCallback, timeout) {
console.log('Entered ConvergenceManager.startDiscovery()');
- if (discoveryStarted)
- throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Discovery has been started.');
-
var args = validator_.validateArgs(arguments, [
{name: 'successCallback', type: types_.LISTENER, values: ['onfound', 'onfinished' ]},
{name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true},
]);
// Indicate, that discovery procedure is on
- if (discoveryStarted === true)
+ if (discoveryStarted === true) {
throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Discovery has already started.');
+ }
discoveryStarted = true;
}, function(result) {
if (native_.isFailure(result)) {
native_.callIfPossible(errorCallback, native_.getErrorObject(result));
+ discoveryStarted = false;
}
});