Skip to content

Commit

Permalink
Merge pull request #36 from euforic/TIMOB-14267
Browse files Browse the repository at this point in the history
[TIMOB-14267] LiveView - Running multiple instances of the application on iOS and Android, iOS instances lose connection to LiveView Server
  • Loading branch information
Christian Sullivan committed Jun 27, 2013
2 parents ba550f8 + db5f310 commit 5375660
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
12 changes: 8 additions & 4 deletions build/liveview.js
Expand Up @@ -387,8 +387,13 @@ Module._includeNative = function(){
* @api private
*/

Module.patch = function (globalCtx, port, url) {
Module._url = url || 'FSERVER_HOST';
Module.patch = function (globalCtx, url, port) {

var defaultURL = (process.platform === 'android' && process.hardware === 'sdk')
? '10.0.2.2'
: 'FSERVER_HOST';

Module._url = url || defaultURL;
Module._port = port || 8324;
Module._requireNative = globalCtx.require;
Module.evtServer && Module.evtServer.close();
Expand Down Expand Up @@ -543,7 +548,6 @@ Module.prototype._getRemoteSource = function(file,timeout){
request.cache = false;
request.open("GET", file);
request.send();

while(!rsp){
if (request.readyState === 4 ) {
if (request.status !== 200) {
Expand All @@ -553,7 +557,7 @@ Module.prototype._getRemoteSource = function(file,timeout){
rsp = request.responseText;
} else if ((expireTime - (new Date()).getTime()) <= 0) {
rsp = true;
throw new Error('[LiveView]', 'File Server unavailable. Host Unreachable');
throw new Error('[LiveView] File Server unavailable. Host Unreachable');
}
}

Expand Down
2 changes: 1 addition & 1 deletion build/liveview.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions hook/lvhook.js
Expand Up @@ -155,11 +155,6 @@ exports.init = function(logger, config, cli) {
iface(function(interfaces) {
var names = Object.keys(interfaces).sort(),
ipAddr;

if (cli.argv.platform == 'android' && cli.argv.target == 'emulator') {
// android emulator is special
ipAddr = '10.0.2.2';
} else {
// note: this finds the first physical interface which may not necessarily be the default gateway interface
for (var i = 0; i < names.length; i++) {
if (interfaces[names[i]].macAddress) {
Expand All @@ -173,7 +168,6 @@ exports.init = function(logger, config, cli) {
break;
}
}
}

if (ipAddr) {
fs.writeFileSync(liveviewJS, fs.readFileSync(liveviewJS).toString().replace(/FSERVER_HOST/g, ipAddr).replace(/TCP_HOST/g, ipAddr));
Expand Down
12 changes: 8 additions & 4 deletions lib/platform/require.js
Expand Up @@ -73,8 +73,13 @@ Module._includeNative = function(){
* @api private
*/

Module.patch = function (globalCtx, port, url) {
Module._url = url || 'FSERVER_HOST';
Module.patch = function (globalCtx, url, port) {

var defaultURL = (process.platform === 'android' && process.hardware === 'sdk')
? '10.0.2.2'
: 'FSERVER_HOST';

Module._url = url || defaultURL;
Module._port = port || 8324;
Module._requireNative = globalCtx.require;
Module.evtServer && Module.evtServer.close();
Expand Down Expand Up @@ -229,7 +234,6 @@ Module.prototype._getRemoteSource = function(file,timeout){
request.cache = false;
request.open("GET", file);
request.send();

while(!rsp){
if (request.readyState === 4 ) {
if (request.status !== 200) {
Expand All @@ -239,7 +243,7 @@ Module.prototype._getRemoteSource = function(file,timeout){
rsp = request.responseText;
} else if ((expireTime - (new Date()).getTime()) <= 0) {
rsp = true;
throw new Error('[LiveView]', 'File Server unavailable. Host Unreachable');
throw new Error('[LiveView] File Server unavailable. Host Unreachable');
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "liveview",
"version": "0.1.25",
"version": "0.1.26",
"description": "Titanium Live Realtime App Development",
"main": "index.js",
"private": true,
Expand Down

0 comments on commit 5375660

Please sign in to comment.