"use strict";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 ### 发送更新通知请求`);
    const json = _cliSharedUtils.fs.readJsonSync(_path.default.resolve(_cliSharedUtils.projectPath, 'client.json'));
    console.log(json);

    // 给游戏前台发送更新通知
    const gameRequrl = `http://${json.client}:49517/update`;
    const reqGame = _http.default.request({
      host: json.client,
      port: 49517,
      path: '/update',
      timeout: 2000
    }, (res) => {
      (0, _cliSharedUtils.info)(`### App Server ### 给引擎发送更新通知请求: ${gameRequrl} 成功`);
    }).on('error', () => {
      (0, _cliSharedUtils.info)(`### App Server ### 给引擎发送更新通知请求: ${gameRequrl} 失败`);

      // 给调试器发送
      const requrl = `http://${json.client}:39517/update`;
      const req = _http.default.request({
        host: json.client,
        port: 39517,
        path: '/update',
        timeout: 2000
      }, (res) => {
        (0, _cliSharedUtils.info)(`### App Server ### 发送自动更新调试器器请求: ${requrl} 成功`);
      }).on('error', () => {

        // 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 ### 给引擎发送更新通知请求: ${gameRequrl} 超时: 3000ms`);
      reqGame.abort();
    });
    reqGame.end();
  } catch (error) {

    // info(`### App Server ### 没找到client信息`)
  }}var _default = exports.default =
notify;