Skip to content

Commit

Permalink
Merge pull request #106 from infosia/TIMOB-25072
Browse files Browse the repository at this point in the history
[TIMOB-25072] Wait for server response without using "while loop"
  • Loading branch information
feons committed Sep 6, 2017
2 parents 82e8111 + bd502ca commit e1d5641
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions build/liveview.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,20 @@
request.open('GET', url);
request.setRequestHeader('x-platform', this.platform);
request.send();

//
// Windows only private API: _waitForResponse() waits for the response from the server.
//
if (this.platform === 'windows' && request._waitForResponse) {
request._waitForResponse();
if (request.readyState === 4 || request.status === 404) {
rsp = request.status === 200 ? request.responseText : false;
} else {
throw new Error('[LiveView] File Server unavailable. Host Unreachable @ ' + Module._url + ':' + Module._port + '\n[LiveView] Please ensure your device and computer are on the same network and the port is not blocked.');
}
done = true;
}

while (!done) {
if (request.readyState === 4 || request.status === 404) {
rsp = request.status === 200 ? request.responseText : false;
Expand Down
14 changes: 14 additions & 0 deletions lib/platform/require.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,20 @@ Module.prototype._getRemoteSource = function (file, timeout) {
request.open('GET', url);
request.setRequestHeader('x-platform', this.platform);
request.send();

//
// Windows only private API: _waitForResponse() waits for the response from the server.
//
if (this.platform === 'windows' && request._waitForResponse) {
request._waitForResponse();
if (request.readyState === 4 || request.status === 404) {
rsp = request.status === 200 ? request.responseText : false;
} else {
throw new Error('[LiveView] File Server unavailable. Host Unreachable @ ' + Module._url + ':' + Module._port + '\n[LiveView] Please ensure your device and computer are on the same network and the port is not blocked.');
}
done = true;
}

while (!done) {
if (request.readyState === 4 || request.status === 404) {
rsp = (request.status === 200) ? request.responseText : false;
Expand Down

0 comments on commit e1d5641

Please sign in to comment.