Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 319a512

Browse files
committedJan 9, 2021
Fix app launcher
1 parent 9f49529 commit 319a512

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed
 

‎app-launcher/http-server.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
*/
1515

1616
var http = require('http');
17+
var Util = require('./util.js');
1718

18-
function HTTPServer(entries, isVerbose = false) {
19+
function HTTPServer(entries, onDefaultEntryHandler, isVerbose = false) {
1920
// Initialize properties
2021
this.mEntries = [];
22+
this.mOnDefaultEntryHandler = onDefaultEntryHandler;
2123
this.mServer = http.createServer();
2224

2325
// Initial http server entries
@@ -65,7 +67,7 @@ HTTPServer.prototype._onHTTPRequest = function (request, response, data) {
6567
}
6668
}
6769
if (!entryFound) {
68-
responseParams = onGetControlpadPage(request, data);
70+
responseParams = this.mOnDefaultEntryHandler(request, data);
6971
}
7072
response.setHeader('Content-Length', responseParams.message.length);
7173
response.writeHead(responseParams.code);

‎app-launcher/index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@ var onGetControlpadPage = function (request, data) {
6464
return html;
6565
};
6666

67-
var results = {message: RESULT_FAILED, code: 404};
67+
var results = {message: 'Not found ' + request.url, code: 404};
6868

6969
var urlTokens = Util.parseUrl(request.url);
70-
var controlpadDir = path.join(Util.getAntRootDir(), 'controlpad');
70+
var controlpadDir = path.join(
71+
Util.getAntRootDir(),
72+
'app-launcher',
73+
'controlpad'
74+
);
7175
if (urlTokens.length == 0) {
7276
var filePath = path.join(controlpadDir, '/index.html');
7377

@@ -81,7 +85,6 @@ var onGetControlpadPage = function (request, data) {
8185
for (var i = 0; i < urlTokens.length; i++) {
8286
filePath = path.join(filePath, urlTokens[i]);
8387
}
84-
console.log('read: ' + filePath);
8588
if (fs.existsSync(filePath)) {
8689
results.message = fs.readFileSync(filePath);
8790
results.code = 200;
@@ -396,7 +399,11 @@ var mainLoop = function () {
396399
console.log('ANT app launcher daemon start');
397400

398401
// Initialize app manager and HTTP server
399-
gHTTPServer = new HTTPServer(gInitialHTTPServerEntries, gConfig.isVerbose);
402+
gHTTPServer = new HTTPServer(
403+
gInitialHTTPServerEntries,
404+
onGetControlpadPage,
405+
gConfig.isVerbose
406+
);
400407
gAppManager = new AppManager(onAppAdded, onAppRemoved);
401408
gCompanionAdapter = new CompanionAdapter();
402409

‎app-launcher/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ Util.prototype.getIPAddress = function (nameHead) {
4747
return undefined;
4848
};
4949

50-
module.exports = Util;
50+
module.exports = new Util();

‎scripts/prepare-ubuntu.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ then
1919
${SUDO} apt-get install -y cmake git glib-2.0 \
2020
libdbus-1-dev libdbus-glib-1-2 libdbus-glib-1-dev python
2121
${SUDO} apt-get install -y software-properties-common
22+
${SUDO} apt-get install -y libcurl3
2223
${SUDO} apt-get install -y libcurl4-openssl-dev
2324
${SUDO} apt-get install -y libtar-dev
2425
${SUDO} apt-get install -y

0 commit comments

Comments
 (0)
Please sign in to comment.