@yuebai008/cli
Version:
Command line interface for rapid qg-minigame development
48 lines (43 loc) • 2.47 kB
JavaScript
;var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");_Object$defineProperty(exports, "__esModule", { value: true });exports["default"] = void 0;var _path = _interopRequireDefault(require("path"));
var _http = _interopRequireDefault(require("http"));
var _cliSharedUtils = require("../cli-shared-utils");
function notify() {
try {
(0, _cliSharedUtils.info)("### App Server ### \u53D1\u9001\u66F4\u65B0\u901A\u77E5\u8BF7\u6C42");
var json = _cliSharedUtils.fs.readJsonSync(_path["default"].resolve(_cliSharedUtils.projectPath, 'client.json'));
console.log(json);
// 给游戏前台发送更新通知
var gameRequrl = "http://".concat(json.client, ":49517/update");
var reqGame = _http["default"].request({
host: json.client,
port: 49517,
path: '/update',
timeout: 2000
}, function (res) {
(0, _cliSharedUtils.info)("### App Server ### \u7ED9\u5F15\u64CE\u53D1\u9001\u66F4\u65B0\u901A\u77E5\u8BF7\u6C42: ".concat(gameRequrl, " \u6210\u529F"));
}).on('error', function () {
(0, _cliSharedUtils.info)("### App Server ### \u7ED9\u5F15\u64CE\u53D1\u9001\u66F4\u65B0\u901A\u77E5\u8BF7\u6C42: ".concat(gameRequrl, " \u5931\u8D25"));
// 给调试器发送
var requrl = "http://".concat(json.client, ":39517/update");
var req = _http["default"].request({
host: json.client,
port: 39517,
path: '/update',
timeout: 2000
}, function (res) {
(0, _cliSharedUtils.info)("### App Server ### \u53D1\u9001\u81EA\u52A8\u66F4\u65B0\u8C03\u8BD5\u5668\u5668\u8BF7\u6C42: ".concat(requrl, " \u6210\u529F"));
}).on('error', function () {
// error(`### App Server ### 发送自动更新调试器请求: ${requrl} 失败: ${err.message}`)
}).on('timeout', function () {// error(`### App Server ### 发送自动更新调试器请求: ${requrl} 超时: 3000ms`)
req.abort();
});
req.end();
}).on('timeout', function () {
(0, _cliSharedUtils.info)("### App Server ### \u7ED9\u5F15\u64CE\u53D1\u9001\u66F4\u65B0\u901A\u77E5\u8BF7\u6C42: ".concat(gameRequrl, " \u8D85\u65F6: 3000ms"));
reqGame.abort();
});
reqGame.end();
} catch (error) {
// info(`### App Server ### 没找到client信息`)
}}var _default = exports["default"] =
notify;