cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject git commit: Added dynamic ip updating.
Date Tue, 03 Jun 2014 21:17:20 GMT
Repository: cordova-app-harness
Updated Branches:
  refs/heads/master fd435c858 -> 5385919a6


Added dynamic ip updating.

Also added an option to skip caching when getting the address.

Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/5385919a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/5385919a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/5385919a

Branch: refs/heads/master
Commit: 5385919a6763581f18cb82635d631deabadddc14
Parents: fd435c8
Author: Max Woghiren <max.woghiren@gmail.com>
Authored: Tue Jun 3 17:16:55 2014 -0400
Committer: Max Woghiren <max.woghiren@gmail.com>
Committed: Tue Jun 3 17:16:55 2014 -0400

----------------------------------------------------------------------
 www/cdvah/js/HarnessServer.js |  4 ++--
 www/cdvah/js/ListCtrl.js      | 14 ++++++++++----
 2 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/5385919a/www/cdvah/js/HarnessServer.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/HarnessServer.js b/www/cdvah/js/HarnessServer.js
index 8b10f94..5cda1db 100644
--- a/www/cdvah/js/HarnessServer.js
+++ b/www/cdvah/js/HarnessServer.js
@@ -322,8 +322,8 @@
             return server.start();
         }
 
-        function getListenAddress() {
-            if (listenAddress) {
+        function getListenAddress(skipCache) {
+            if (listenAddress && !skipCache) {
                 return $q.when(listenAddress);
             }
             var deferred = $q.defer();

http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/5385919a/www/cdvah/js/ListCtrl.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/ListCtrl.js b/www/cdvah/js/ListCtrl.js
index f402e6d..14f616d 100644
--- a/www/cdvah/js/ListCtrl.js
+++ b/www/cdvah/js/ListCtrl.js
@@ -31,10 +31,16 @@
             .then(function() {
                 return HarnessServer.start();
             }).then(function() {
-                return HarnessServer.getListenAddress()
-                .then(function(value) {
-                    $scope.ipAddress = value;
-                });
+                var getInfoCallback = function() {
+                    HarnessServer.getListenAddress(/* skipCache */ true)
+                    .then(function(value) {
+                        $scope.ipAddress = value ? value : 'Failed to start server';
+                    });
+                };
+
+                // When getInfo is called, the callback is retained and called every time
network info changes.
+                // The callback updates the IP.
+                navigator.connection.getInfo(getInfoCallback);
             }, function() {
                 $scope.ipAddress = 'Failed to start server';
             });


Mime
View raw message