2017-07-12 16:44:44 +08:00
|
|
|
'use strict';
|
2017-07-08 18:15:41 +08:00
|
|
|
|
2017-07-12 16:44:44 +08:00
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
exports.start = start;
|
|
|
|
exports.onRequest = onRequest;
|
|
|
|
exports.sendResponse = sendResponse;
|
|
|
|
exports.stop = stop;
|
2023-12-14 22:29:17 +08:00
|
|
|
exports.isRunning = isRunning;
|
2017-07-12 16:44:44 +08:00
|
|
|
|
|
|
|
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';
|
2023-12-14 22:29:17 +08:00
|
|
|
var ISRUNNING_FUNCTION = 'isRunning';
|
2017-07-12 16:44:44 +08:00
|
|
|
|
|
|
|
function start(success_callback, error_callback, port) {
|
2017-07-11 22:45:27 +08:00
|
|
|
var params = [];
|
|
|
|
if (port) {
|
|
|
|
params.push(port);
|
|
|
|
}
|
2017-07-12 16:44:44 +08:00
|
|
|
(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, []);
|
|
|
|
}
|
2023-12-14 22:29:17 +08:00
|
|
|
function isRunning(success_callback, error_callback) {
|
|
|
|
(0, _exec2.default)(success_callback, error_callback, WEBSERVER_CLASS, ISRUNNING_FUNCTION, []);
|
|
|
|
}
|