"use strict"; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var multicast_dns_1 = __importDefault(require("multicast-dns")); var Controller_1 = __importDefault(require("../controller/Controller")); var ELanType_1 = __importDefault(require("../ts/enum/ELanType")); var logger_1 = require("../utils/logger"); var Mdns = (function () { function Mdns(params) { var onResponseCb = params.onResponseCb, queryParams = params.queryParams, queryCb = params.queryCb; this.mdns = new multicast_dns_1.default(); this.onResponse(onResponseCb); this.query(queryParams, queryCb); } Mdns.createInstance = function (params) { if (!Mdns.instance) { Mdns.instance = new Mdns(params); } return Mdns.instance; }; Mdns.prototype.query = function (params, callback) { if (!this.mdns) { this.mdns = new multicast_dns_1.default(); } this.mdns.query(params, callback); }; Mdns.prototype.onResponse = function (callback) { this.mdns.on('response', function (packet) { var _a, _b, _c, _d, _e, _f, _g, _h, _j; var answers = packet.answers; if (Array.isArray(answers)) { var tmp = {}; var key = ''; var _loop_1 = function (i) { var data = answers[i].data; switch (answers[i].type) { case 'PTR': if ("".concat(data).indexOf('ewelink') === -1) { return { value: void 0 }; } tmp.ptr = data; break; case 'A': tmp.a = data; break; case 'SRV': tmp.srv = data; break; case 'TXT': var arr = data.toString().split(/(?