-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathwebserver.js
43 lines (34 loc) · 1.25 KB
/
webserver.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.start = start;
exports.onRequest = onRequest;
exports.sendResponse = sendResponse;
exports.stop = stop;
var _exec = require('cordova/exec');
var _exec2 = _interopRequireDefault(_exec);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var WEBSERVER_CLASS = 'Webserver';
var START_FUNCTION = 'start';
var ONREQUEST_FUNCTION = 'onRequest';
var SENDRESPONSE_FUNCION = 'sendResponse';
var STOP_FUNCTION = 'stop';
function start(success_callback, error_callback, port) {
var params = [];
if (port) {
params.push(port);
}
(0, _exec2.default)(success_callback, error_callback, WEBSERVER_CLASS, START_FUNCTION, params);
}
function onRequest(success_callback) {
(0, _exec2.default)(success_callback, function (error) {
console.error(error);
}, WEBSERVER_CLASS, ONREQUEST_FUNCTION, []);
}
function sendResponse(requestId, params, success_callback, error_callback) {
(0, _exec2.default)(success_callback, error_callback, WEBSERVER_CLASS, SENDRESPONSE_FUNCION, [requestId, params]);
}
function stop(success_callback, error_callback) {
(0, _exec2.default)(success_callback, error_callback, WEBSERVER_CLASS, STOP_FUNCTION, []);
}