50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.start = start;
|
|
exports.onRequest = onRequest;
|
|
exports.sendResponse = sendResponse;
|
|
exports.sendFile = sendFile;
|
|
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 SENDFILE_FUNCION = 'sendFileResponse';
|
|
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 sendFile(requestId, params, success_callback, error_callback) {
|
|
(0, _exec2.default)(success_callback, error_callback, WEBSERVER_CLASS, SENDFILE_FUNCION, [requestId, params]);
|
|
}
|
|
|
|
function stop(success_callback, error_callback) {
|
|
(0, _exec2.default)(success_callback, error_callback, WEBSERVER_CLASS, STOP_FUNCTION, []);
|
|
}
|