[Convergence] Set discoveryStarted to false in error callback. 29/102029/2
authorTomasz Marciniak <t.marciniak@samsung.com>
Sun, 4 Dec 2016 09:50:20 +0000 (18:50 +0900)
committerTomasz Marciniak <t.marciniak@samsung.com>
Mon, 5 Dec 2016 23:29:59 +0000 (08:29 +0900)
[Verification] Code compiles.

Change-Id: I05aa3c04f5dfe2232495c08c35c15921f37747a6
Signed-off-by: Tomasz Marciniak <t.marciniak@samsung.com>
src/convergence/convergence_api.js

index 3d4650d..8abc3c2 100644 (file)
@@ -135,9 +135,6 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback,
   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},
@@ -145,8 +142,9 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback,
   ]);
 
   // 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;
 
@@ -225,6 +223,7 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback,
                }, function(result) {
                     if (native_.isFailure(result)) {
                       native_.callIfPossible(errorCallback, native_.getErrorObject(result));
+                      discoveryStarted = false;
                     }
                });