@xibosignage/xibo-communication-framework 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/modules/xmr/xmr.d.ts +1 -0
- package/dist/xibo-communication-framework.cjs.js +135 -296
- package/dist/xibo-communication-framework.cjs.js.map +1 -1
- package/dist/xibo-communication-framework.d.ts +1 -0
- package/dist/xibo-communication-framework.esm.js +135 -296
- package/dist/xibo-communication-framework.esm.js.map +1 -1
- package/dist/xibo-communication-framework.js +135 -296
- package/dist/xibo-communication-framework.min.js +3 -1
- package/dist/xibo-communication-framework.min.js.map +1 -1
- package/package.json +2 -1
|
@@ -48,274 +48,113 @@ var XiboCommunicationFramework = (function (exports, luxon) {
|
|
|
48
48
|
writable: true
|
|
49
49
|
}) : e[r] = t, e;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function h(r, e, n, o) {
|
|
79
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
80
|
-
a = Object.create(i.prototype);
|
|
81
|
-
return c(a, "_invoke", function (r, e, n) {
|
|
82
|
-
var o = 1;
|
|
83
|
-
return function (i, a) {
|
|
84
|
-
if (3 === o) throw Error("Generator is already running");
|
|
85
|
-
if (4 === o) {
|
|
86
|
-
if ("throw" === i) throw a;
|
|
87
|
-
return {
|
|
88
|
-
value: t,
|
|
89
|
-
done: true
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
for (n.method = i, n.arg = a;;) {
|
|
93
|
-
var u = n.delegate;
|
|
94
|
-
if (u) {
|
|
95
|
-
var c = d(u, n);
|
|
96
|
-
if (c) {
|
|
97
|
-
if (c === f) continue;
|
|
98
|
-
return c;
|
|
99
|
-
}
|
|
51
|
+
function _regenerator() {
|
|
52
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
53
|
+
var e,
|
|
54
|
+
t,
|
|
55
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
56
|
+
n = r.iterator || "@@iterator",
|
|
57
|
+
o = r.toStringTag || "@@toStringTag";
|
|
58
|
+
function i(r, n, o, i) {
|
|
59
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
60
|
+
u = Object.create(c.prototype);
|
|
61
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
62
|
+
var i,
|
|
63
|
+
c,
|
|
64
|
+
u,
|
|
65
|
+
f = 0,
|
|
66
|
+
p = o || [],
|
|
67
|
+
y = false,
|
|
68
|
+
G = {
|
|
69
|
+
p: 0,
|
|
70
|
+
n: 0,
|
|
71
|
+
v: e,
|
|
72
|
+
a: d,
|
|
73
|
+
f: d.bind(e, 4),
|
|
74
|
+
d: function (t, r) {
|
|
75
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
100
76
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
77
|
+
};
|
|
78
|
+
function d(r, n) {
|
|
79
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
80
|
+
var o,
|
|
81
|
+
i = p[t],
|
|
82
|
+
d = G.p,
|
|
83
|
+
l = i[2];
|
|
84
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
85
|
+
}
|
|
86
|
+
if (o || r > 1) return a;
|
|
87
|
+
throw y = true, n;
|
|
88
|
+
}
|
|
89
|
+
return function (o, p, l) {
|
|
90
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
91
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
92
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
93
|
+
try {
|
|
94
|
+
if (f = 2, i) {
|
|
95
|
+
if (c || (o = "next"), t = i[o]) {
|
|
96
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
97
|
+
if (!t.done) return t;
|
|
98
|
+
u = t.value, c < 2 && (c = 0);
|
|
99
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
100
|
+
i = e;
|
|
101
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
102
|
+
} catch (t) {
|
|
103
|
+
i = e, c = 1, u = t;
|
|
104
|
+
} finally {
|
|
105
|
+
f = 1;
|
|
113
106
|
}
|
|
114
|
-
"throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg);
|
|
115
107
|
}
|
|
108
|
+
return {
|
|
109
|
+
value: t,
|
|
110
|
+
done: y
|
|
111
|
+
};
|
|
116
112
|
};
|
|
117
|
-
}(r,
|
|
118
|
-
}
|
|
119
|
-
function s(t, r, e) {
|
|
120
|
-
try {
|
|
121
|
-
return {
|
|
122
|
-
type: "normal",
|
|
123
|
-
arg: t.call(r, e)
|
|
124
|
-
};
|
|
125
|
-
} catch (t) {
|
|
126
|
-
return {
|
|
127
|
-
type: "throw",
|
|
128
|
-
arg: t
|
|
129
|
-
};
|
|
130
|
-
}
|
|
113
|
+
}(r, o, i), true), u;
|
|
131
114
|
}
|
|
132
|
-
|
|
133
|
-
var f = {};
|
|
115
|
+
var a = {};
|
|
134
116
|
function Generator() {}
|
|
135
117
|
function GeneratorFunction() {}
|
|
136
118
|
function GeneratorFunctionPrototype() {}
|
|
137
|
-
|
|
138
|
-
c(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l);
|
|
145
|
-
function g(t) {
|
|
146
|
-
["next", "throw", "return"].forEach(function (r) {
|
|
147
|
-
c(t, r, function (t) {
|
|
148
|
-
return this._invoke(r, t);
|
|
149
|
-
});
|
|
150
|
-
});
|
|
119
|
+
t = Object.getPrototypeOf;
|
|
120
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
121
|
+
return this;
|
|
122
|
+
}), t),
|
|
123
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
124
|
+
function f(e) {
|
|
125
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
151
126
|
}
|
|
152
|
-
|
|
153
|
-
function e(o, i, a, u) {
|
|
154
|
-
var c = s(t[o], t, i);
|
|
155
|
-
if ("throw" !== c.type) {
|
|
156
|
-
var h = c.arg,
|
|
157
|
-
f = h.value;
|
|
158
|
-
return f && "object" == typeof f && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) {
|
|
159
|
-
e("next", t, a, u);
|
|
160
|
-
}, function (t) {
|
|
161
|
-
e("throw", t, a, u);
|
|
162
|
-
}) : r.resolve(f).then(function (t) {
|
|
163
|
-
h.value = t, a(h);
|
|
164
|
-
}, function (t) {
|
|
165
|
-
return e("throw", t, a, u);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
u(c.arg);
|
|
169
|
-
}
|
|
170
|
-
var o;
|
|
171
|
-
c(this, "_invoke", function (t, n) {
|
|
172
|
-
function i() {
|
|
173
|
-
return new r(function (r, o) {
|
|
174
|
-
e(t, n, r, o);
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
return o = o ? o.then(i, i) : i();
|
|
178
|
-
}, true);
|
|
179
|
-
}
|
|
180
|
-
function d(r, e) {
|
|
181
|
-
var n = e.method,
|
|
182
|
-
o = r.i[n];
|
|
183
|
-
if (o === t) return e.delegate = null, "throw" === n && r.i.return && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f;
|
|
184
|
-
var i = s(o, r.i, e.arg);
|
|
185
|
-
if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f;
|
|
186
|
-
var a = i.arg;
|
|
187
|
-
return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f);
|
|
188
|
-
}
|
|
189
|
-
function w(t) {
|
|
190
|
-
this.tryEntries.push(t);
|
|
191
|
-
}
|
|
192
|
-
function m(r) {
|
|
193
|
-
var e = r[4] || {};
|
|
194
|
-
e.type = "normal", e.arg = t, r[4] = e;
|
|
195
|
-
}
|
|
196
|
-
function Context(t) {
|
|
197
|
-
this.tryEntries = [[-1]], t.forEach(w, this), this.reset(true);
|
|
198
|
-
}
|
|
199
|
-
function x(r) {
|
|
200
|
-
if (null != r) {
|
|
201
|
-
var e = r[i];
|
|
202
|
-
if (e) return e.call(r);
|
|
203
|
-
if ("function" == typeof r.next) return r;
|
|
204
|
-
if (!isNaN(r.length)) {
|
|
205
|
-
var o = -1,
|
|
206
|
-
a = function e() {
|
|
207
|
-
for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = false, e;
|
|
208
|
-
return e.value = t, e.done = true, e;
|
|
209
|
-
};
|
|
210
|
-
return a.next = a;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
throw new TypeError(typeof r + " is not iterable");
|
|
214
|
-
}
|
|
215
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) {
|
|
216
|
-
var r = "function" == typeof t && t.constructor;
|
|
217
|
-
return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name));
|
|
218
|
-
}, r.mark = function (t) {
|
|
219
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t;
|
|
220
|
-
}, r.awrap = function (t) {
|
|
221
|
-
return {
|
|
222
|
-
__await: t
|
|
223
|
-
};
|
|
224
|
-
}, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () {
|
|
127
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
225
128
|
return this;
|
|
226
|
-
}),
|
|
227
|
-
void 0 === i && (i = Promise);
|
|
228
|
-
var a = new AsyncIterator(h(t, e, n, o), i);
|
|
229
|
-
return r.isGeneratorFunction(e) ? a : a.next().then(function (t) {
|
|
230
|
-
return t.done ? t.value : a.next();
|
|
231
|
-
});
|
|
232
|
-
}, g(v), c(v, u, "Generator"), c(v, i, function () {
|
|
233
|
-
return this;
|
|
234
|
-
}), c(v, "toString", function () {
|
|
129
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
235
130
|
return "[object Generator]";
|
|
236
|
-
}),
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
return function t() {
|
|
241
|
-
for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = false, t;
|
|
242
|
-
return t.done = true, t;
|
|
131
|
+
}), (_regenerator = function () {
|
|
132
|
+
return {
|
|
133
|
+
w: i,
|
|
134
|
+
m: f
|
|
243
135
|
};
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
function n(t) {
|
|
259
|
-
a.type = "throw", a.arg = r, e.next = t;
|
|
260
|
-
}
|
|
261
|
-
for (var o = e.tryEntries.length - 1; o >= 0; --o) {
|
|
262
|
-
var i = this.tryEntries[o],
|
|
263
|
-
a = i[4],
|
|
264
|
-
u = this.prev,
|
|
265
|
-
c = i[1],
|
|
266
|
-
h = i[2];
|
|
267
|
-
if (-1 === i[0]) return n("end"), false;
|
|
268
|
-
if (!c && !h) throw Error("try statement without catch or finally");
|
|
269
|
-
if (null != i[0] && i[0] <= u) {
|
|
270
|
-
if (u < c) return this.method = "next", this.arg = t, n(c), true;
|
|
271
|
-
if (u < h) return n(h), false;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
},
|
|
275
|
-
abrupt: function (t, r) {
|
|
276
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
277
|
-
var n = this.tryEntries[e];
|
|
278
|
-
if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) {
|
|
279
|
-
var o = n;
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null);
|
|
284
|
-
var i = o ? o[4] : {};
|
|
285
|
-
return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i);
|
|
286
|
-
},
|
|
287
|
-
complete: function (t, r) {
|
|
288
|
-
if ("throw" === t.type) throw t.arg;
|
|
289
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f;
|
|
290
|
-
},
|
|
291
|
-
finish: function (t) {
|
|
292
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
293
|
-
var e = this.tryEntries[r];
|
|
294
|
-
if (e[2] === t) return this.complete(e[4], e[3]), m(e), f;
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
catch: function (t) {
|
|
298
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
299
|
-
var e = this.tryEntries[r];
|
|
300
|
-
if (e[0] === t) {
|
|
301
|
-
var n = e[4];
|
|
302
|
-
if ("throw" === n.type) {
|
|
303
|
-
var o = n.arg;
|
|
304
|
-
m(e);
|
|
305
|
-
}
|
|
306
|
-
return o;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
throw Error("illegal catch attempt");
|
|
310
|
-
},
|
|
311
|
-
delegateYield: function (r, e, n) {
|
|
312
|
-
return this.delegate = {
|
|
313
|
-
i: x(r),
|
|
314
|
-
r: e,
|
|
315
|
-
n: n
|
|
316
|
-
}, "next" === this.method && (this.arg = t), f;
|
|
136
|
+
})();
|
|
137
|
+
}
|
|
138
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
139
|
+
var i = Object.defineProperty;
|
|
140
|
+
try {
|
|
141
|
+
i({}, "", {});
|
|
142
|
+
} catch (e) {
|
|
143
|
+
i = 0;
|
|
144
|
+
}
|
|
145
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
146
|
+
function o(r, n) {
|
|
147
|
+
_regeneratorDefine(e, r, function (e) {
|
|
148
|
+
return this._invoke(r, n, e);
|
|
149
|
+
});
|
|
317
150
|
}
|
|
318
|
-
|
|
151
|
+
r ? i ? i(e, r, {
|
|
152
|
+
value: n,
|
|
153
|
+
enumerable: !t,
|
|
154
|
+
configurable: !t,
|
|
155
|
+
writable: !t
|
|
156
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
157
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
319
158
|
}
|
|
320
159
|
function _toPrimitive(t, r) {
|
|
321
160
|
if ("object" != typeof t || !t) return t;
|
|
@@ -389,10 +228,10 @@ var XiboCommunicationFramework = (function (exports, luxon) {
|
|
|
389
228
|
}, {
|
|
390
229
|
key: "init",
|
|
391
230
|
value: function () {
|
|
392
|
-
var _init = _asyncToGenerator(/*#__PURE__*/
|
|
231
|
+
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
393
232
|
var _this = this;
|
|
394
|
-
return
|
|
395
|
-
while (1) switch (_context.
|
|
233
|
+
return _regenerator().w(function (_context) {
|
|
234
|
+
while (1) switch (_context.n) {
|
|
396
235
|
case 0:
|
|
397
236
|
this.interval = setInterval(function () {
|
|
398
237
|
if (_this.isConnectionWanted && !_this.isActive()) {
|
|
@@ -402,8 +241,7 @@ var XiboCommunicationFramework = (function (exports, luxon) {
|
|
|
402
241
|
}
|
|
403
242
|
}, 60000);
|
|
404
243
|
case 1:
|
|
405
|
-
|
|
406
|
-
return _context.stop();
|
|
244
|
+
return _context.a(2);
|
|
407
245
|
}
|
|
408
246
|
}, _callee, this);
|
|
409
247
|
}));
|
|
@@ -415,20 +253,21 @@ var XiboCommunicationFramework = (function (exports, luxon) {
|
|
|
415
253
|
}, {
|
|
416
254
|
key: "start",
|
|
417
255
|
value: function () {
|
|
418
|
-
var _start = _asyncToGenerator(/*#__PURE__*/
|
|
256
|
+
var _start = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(url, cmsKey) {
|
|
419
257
|
var _this2 = this;
|
|
420
|
-
|
|
421
|
-
|
|
258
|
+
var _t;
|
|
259
|
+
return _regenerator().w(function (_context2) {
|
|
260
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
422
261
|
case 0:
|
|
423
262
|
if (!(!this.channel || this.channel === 'unknown')) {
|
|
424
|
-
_context2.
|
|
263
|
+
_context2.n = 1;
|
|
425
264
|
break;
|
|
426
265
|
}
|
|
427
266
|
console.error('Xmr::start: channel unknown, XMR will be disabled');
|
|
428
|
-
return _context2.
|
|
429
|
-
case
|
|
267
|
+
return _context2.a(2);
|
|
268
|
+
case 1:
|
|
430
269
|
if (!(this.url === 'DISABLED')) {
|
|
431
|
-
_context2.
|
|
270
|
+
_context2.n = 2;
|
|
432
271
|
break;
|
|
433
272
|
}
|
|
434
273
|
console.info('Xmr::start: XMR disabled');
|
|
@@ -436,46 +275,46 @@ var XiboCommunicationFramework = (function (exports, luxon) {
|
|
|
436
275
|
if (this.isActive()) {
|
|
437
276
|
stop();
|
|
438
277
|
}
|
|
439
|
-
return _context2.
|
|
440
|
-
case
|
|
278
|
+
return _context2.a(2);
|
|
279
|
+
case 2:
|
|
441
280
|
this.isConnectionWanted = true;
|
|
442
281
|
// Are we already connected?
|
|
443
282
|
if (!(this.isActive() && this.url === url)) {
|
|
444
|
-
_context2.
|
|
283
|
+
_context2.n = 3;
|
|
445
284
|
break;
|
|
446
285
|
}
|
|
447
286
|
console.debug('Xmr::start: already connected to this URL');
|
|
448
287
|
this.cmsKey = cmsKey;
|
|
449
|
-
return _context2.
|
|
450
|
-
case
|
|
288
|
+
return _context2.a(2);
|
|
289
|
+
case 3:
|
|
451
290
|
if (!this.isConnected) {
|
|
452
|
-
_context2.
|
|
291
|
+
_context2.n = 5;
|
|
453
292
|
break;
|
|
454
293
|
}
|
|
455
294
|
console.debug('Xmr::start: already connected but not active, or a different URL');
|
|
456
|
-
_context2.
|
|
295
|
+
_context2.n = 4;
|
|
457
296
|
return this.stop();
|
|
458
|
-
case
|
|
459
|
-
_context2.
|
|
297
|
+
case 4:
|
|
298
|
+
_context2.n = 6;
|
|
460
299
|
break;
|
|
461
|
-
case
|
|
300
|
+
case 5:
|
|
462
301
|
console.debug('Xmr::start: not connected yet');
|
|
463
|
-
case
|
|
302
|
+
case 6:
|
|
464
303
|
// Set the URL and cmsKey.
|
|
465
304
|
this.url = url;
|
|
466
305
|
this.cmsKey = cmsKey;
|
|
467
306
|
console.debug('Xmr::start: connecting to ' + this.url);
|
|
468
|
-
_context2.
|
|
307
|
+
_context2.p = 7;
|
|
469
308
|
this.socket = new WebSocket(this.url);
|
|
470
|
-
_context2.
|
|
309
|
+
_context2.n = 9;
|
|
471
310
|
break;
|
|
472
|
-
case
|
|
473
|
-
_context2.
|
|
474
|
-
|
|
475
|
-
console.debug('Xmr::start: failed connecting to ' + this.url + ', e = ' +
|
|
311
|
+
case 8:
|
|
312
|
+
_context2.p = 8;
|
|
313
|
+
_t = _context2.v;
|
|
314
|
+
console.debug('Xmr::start: failed connecting to ' + this.url + ', e = ' + _t);
|
|
476
315
|
this.emitter.emit('error', 'Failed to connect');
|
|
477
|
-
return _context2.
|
|
478
|
-
case
|
|
316
|
+
return _context2.a(2);
|
|
317
|
+
case 9:
|
|
479
318
|
/**
|
|
480
319
|
* Listener for socket open
|
|
481
320
|
*/
|
|
@@ -538,16 +377,17 @@ var XiboCommunicationFramework = (function (exports, luxon) {
|
|
|
538
377
|
} else if (message.action == 'commandAction' && message.commandCode.startsWith('showStatusWindow')) {
|
|
539
378
|
var split = message.commandCode.split('|');
|
|
540
379
|
_this2.emitter.emit('showStatusWindow', parseInt(split[1]) || 60);
|
|
380
|
+
} else if (message.action == 'commandAction' && message.commandCode.startsWith('forceUpdateChromeOS')) {
|
|
381
|
+
_this2.emitter.emit('forceUpdateChromeOS');
|
|
541
382
|
} else {
|
|
542
383
|
console.error('Xmr::message: unknown action: ' + message.action);
|
|
543
384
|
}
|
|
544
385
|
}
|
|
545
386
|
});
|
|
546
|
-
case
|
|
547
|
-
|
|
548
|
-
return _context2.stop();
|
|
387
|
+
case 10:
|
|
388
|
+
return _context2.a(2);
|
|
549
389
|
}
|
|
550
|
-
}, _callee2, this, [[
|
|
390
|
+
}, _callee2, this, [[7, 8]]);
|
|
551
391
|
}));
|
|
552
392
|
function start(_x, _x2) {
|
|
553
393
|
return _start.apply(this, arguments);
|
|
@@ -557,9 +397,9 @@ var XiboCommunicationFramework = (function (exports, luxon) {
|
|
|
557
397
|
}, {
|
|
558
398
|
key: "stop",
|
|
559
399
|
value: function () {
|
|
560
|
-
var _stop = _asyncToGenerator(/*#__PURE__*/
|
|
561
|
-
return
|
|
562
|
-
while (1) switch (_context3.
|
|
400
|
+
var _stop = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
401
|
+
return _regenerator().w(function (_context3) {
|
|
402
|
+
while (1) switch (_context3.n) {
|
|
563
403
|
case 0:
|
|
564
404
|
console.debug('Xmr::stop');
|
|
565
405
|
if (this.socket) {
|
|
@@ -567,9 +407,8 @@ var XiboCommunicationFramework = (function (exports, luxon) {
|
|
|
567
407
|
this.socket.close();
|
|
568
408
|
this.isConnected = false;
|
|
569
409
|
}
|
|
570
|
-
case
|
|
571
|
-
|
|
572
|
-
return _context3.stop();
|
|
410
|
+
case 1:
|
|
411
|
+
return _context3.a(2);
|
|
573
412
|
}
|
|
574
413
|
}, _callee3, this);
|
|
575
414
|
}));
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
var XiboCommunicationFramework=function(t,e){"use strict";function n(t,e,n,r,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void n(t)}s.done?e(c):Promise.resolve(c).then(r,o)}function r(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function s(t){n(a,o,i,s,c,"next",t)}function c(t){n(a,o,i,s,c,"throw",t)}s(void 0)}))}}function o(t,e,n){return e&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,s(r.key),r)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function i(t,e,n){return(e=s(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(){a=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,n,r){return Object.defineProperty(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r})}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function h(e,n,r,o){var i=n&&n.prototype instanceof d?n:d,a=Object.create(i.prototype);return u(a,"_invoke",function(e,n,r){var o=1;return function(i,a){if(3===o)throw Error("Generator is already running");if(4===o){if("throw"===i)throw a;return{value:t,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var c=x(s,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(1===o)throw o=4,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=3;var u=l(e,n,r);if("normal"===u.type){if(o=r.done?4:2,u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(o=4,r.method="throw",r.arg=u.arg)}}}(e,r,new S(o||[])),!0),a}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=h;var f={};function d(){}function v(){}function p(){}var m={};u(m,i,(function(){return this}));var y=Object.getPrototypeOf,g=y&&y(y(O([])));g&&g!==n&&r.call(g,i)&&(m=g);var w=p.prototype=d.prototype=Object.create(m);function b(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function n(o,i,a,s){var c=l(t[o],t,i);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(h).then((function(t){u.value=t,a(u)}),(function(t){return n("throw",t,a,s)}))}s(c.arg)}var o;u(this,"_invoke",(function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}),!0)}function x(e,n){var r=n.method,o=e.i[r];if(o===t)return n.delegate=null,"throw"===r&&e.i.return&&(n.method="return",n.arg=t,x(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=l(o,e.i,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,f;var a=i.arg;return a?a.done?(n[e.r]=a.value,n.next=e.n,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,f):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,f)}function E(t){this.tryEntries.push(t)}function X(e){var n=e[4]||{};n.type="normal",n.arg=t,e[4]=n}function S(t){this.tryEntries=[[-1]],t.forEach(E,this),this.reset(!0)}function O(e){if(null!=e){var n=e[i];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return a.next=a}}throw new TypeError(typeof e+" is not iterable")}return v.prototype=p,u(w,"constructor",p),u(p,"constructor",v),v.displayName=u(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,u(t,c,"GeneratorFunction")),t.prototype=Object.create(w),t},e.awrap=function(t){return{__await:t}},b(k.prototype),u(k.prototype,s,(function(){return this})),e.AsyncIterator=k,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new k(h(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(w),u(w,c,"Generator"),u(w,i,(function(){return this})),u(w,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.unshift(r);return function t(){for(;n.length;)if((r=n.pop())in e)return t.value=r,t.done=!1,t;return t.done=!0,t}},e.values=O,S.prototype={constructor:S,reset:function(e){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(X),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(t){a.type="throw",a.arg=e,n.next=t}for(var o=n.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i[4],s=this.prev,c=i[1],u=i[2];if(-1===i[0])return r("end"),!1;if(!c&&!u)throw Error("try statement without catch or finally");if(null!=i[0]&&i[0]<=s){if(s<c)return this.method="next",this.arg=t,r(c),!0;if(s<u)return r(u),!1}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r[0]>-1&&r[0]<=this.prev&&this.prev<r[2]){var o=r;break}}o&&("break"===t||"continue"===t)&&o[0]<=e&&e<=o[2]&&(o=null);var i=o?o[4]:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o[2],f):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n[2]===t)return this.complete(n[4],n[3]),X(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n[0]===t){var r=n[4];if("throw"===r.type){var o=r.arg;X(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={i:O(e),r:n,n:r},"next"===this.method&&(this.arg=t),f}},e}function s(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}var c=function(){return o((function t(n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),i(this,"emitter",void 0),i(this,"url",void 0),i(this,"cmsKey",void 0),i(this,"channel",void 0),i(this,"socket",void 0),i(this,"isConnectionWanted",void 0),i(this,"isConnected",void 0),i(this,"lastMessageAt",void 0),i(this,"interval",void 0),this.emitter={emit:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];for(var o=this.events[t]||[],i=0,a=o.length;i<a;i++)o[i].apply(o,n)},events:{},on:function(t,e){var n,r=this;return((n=this.events)[t]||(n[t]=[])).push(e),function(){var n;r.events[t]=null===(n=r.events[t])||void 0===n?void 0:n.filter((function(t){return e!==t}))}}},this.url=null,this.cmsKey=null,this.channel=n,this.isConnected=!1,this.isConnectionWanted=!1,this.lastMessageAt=e.DateTime.now().minus({year:1})}),[{key:"on",value:function(t,e){return this.emitter.on(t,e)}},{key:"init",value:(s=r(a().mark((function t(){var e=this;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.interval=setInterval((function(){e.isConnectionWanted&&!e.isActive()&&(console.debug("Xmr::setInterval: should be active"),e.start(e.url||"DISABLED",e.cmsKey||"n/a"))}),6e4);case 1:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)})},{key:"start",value:(n=r(a().mark((function t(n,r){var o=this;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.channel&&"unknown"!==this.channel){t.next=3;break}return console.error("Xmr::start: channel unknown, XMR will be disabled"),t.abrupt("return");case 3:if("DISABLED"!==this.url){t.next=8;break}return console.info("Xmr::start: XMR disabled"),this.isConnectionWanted=!1,this.isActive()&&stop(),t.abrupt("return");case 8:if(this.isConnectionWanted=!0,!this.isActive()||this.url!==n){t.next=15;break}return console.debug("Xmr::start: already connected to this URL"),this.cmsKey=r,t.abrupt("return");case 15:if(!this.isConnected){t.next=21;break}return console.debug("Xmr::start: already connected but not active, or a different URL"),t.next=19,this.stop();case 19:t.next=22;break;case 21:console.debug("Xmr::start: not connected yet");case 22:this.url=n,this.cmsKey=r,console.debug("Xmr::start: connecting to "+this.url),t.prev=25,this.socket=new WebSocket(this.url),t.next=34;break;case 29:return t.prev=29,t.t0=t.catch(25),console.debug("Xmr::start: failed connecting to "+this.url+", e = "+t.t0),this.emitter.emit("error","Failed to connect"),t.abrupt("return");case 34:this.socket.addEventListener("open",(function(t){console.debug("Xmr::"+t.type),o.socket.readyState===WebSocket.OPEN?(o.socket.send(JSON.stringify({type:"init",key:o.cmsKey,channel:o.channel})),o.isConnected=!0,o.emitter.emit("connected")):console.info("Xmr::"+t.type+": not open yet")})),this.socket.addEventListener("close",(function(t){console.debug("Xmr::"+t.type),o.isConnected=!1,o.emitter.emit("disconnected")})),this.socket.addEventListener("error",(function(t){console.debug("Xmr::"+t.type),o.emitter.emit("error","error")})),this.socket.addEventListener("message",(function(t){if(console.debug(t),o.lastMessageAt=e.DateTime.now(),o.emitter.emit("statusChange",o.lastMessageAt.toISO()||""),"H"===t.data)console.debug("Xmr::message: Heartbeat...");else{var n=JSON.parse(t.data);console.debug("Xmr::message: action is "+n.action);var r=e.DateTime.fromISO(n.createdDt).plus({seconds:parseInt(n.ttl)});if(r<e.DateTime.now())console.debug("Xmr::message: message expired at "+r.toString());else if("collectNow"===n.action)o.emitter.emit("collectNow");else if("screenShot"===n.action)o.emitter.emit("screenShot");else if("licenceCheck"===n.action)o.emitter.emit("licenceCheck");else if("commandAction"==n.action&&n.commandCode.startsWith("showStatusWindow")){var i=n.commandCode.split("|");o.emitter.emit("showStatusWindow",parseInt(i[1])||60)}else console.error("Xmr::message: unknown action: "+n.action)}}));case 38:case"end":return t.stop()}}),t,this,[[25,29]])}))),function(t,e){return n.apply(this,arguments)})},{key:"stop",value:(t=r(a().mark((function t(){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:console.debug("Xmr::stop"),this.socket&&(console.debug("Xmr::stop: closing active socket"),this.socket.close(),this.isConnected=!1);case 2:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})},{key:"isActive",value:function(){return console.debug("Xmr::isActive: lastMessageAt: "+this.lastMessageAt.toString()),this.isConnected&&this.lastMessageAt>e.DateTime.now().minus({minute:15})}}]);var t,n,s}();return t.Xmr=c,t}({},luxon);
|
|
1
|
+
var XiboCommunicationFramework=function(e,t){"use strict";function n(e,t,n,r,o,i,s){try{var c=e[i](s),a=c.value}catch(e){return void n(e)}c.done?t(a):Promise.resolve(a).then(r,o)}function r(e){return function(){var t=this,r=arguments;return new Promise(function(o,i){var s=e.apply(t,r);function c(e){n(s,o,i,c,a,"next",e)}function a(e){n(s,o,i,c,a,"throw",e)}c(void 0)})}}function o(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,a(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(e,t,n){return(t=a(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(){
|
|
2
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
+
var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var s=r&&r.prototype instanceof u?r:u,l=Object.create(s.prototype);return c(l,"_invoke",function(n,r,o){var i,s,c,u=0,l=o||[],f=!1,h={p:0,n:0,v:e,a:m,f:m.bind(e,4),d:function(t,n){return i=t,s=0,c=e,h.n=n,a}};function m(n,r){for(s=n,c=r,t=0;!f&&u&&!o&&t<l.length;t++){var o,i=l[t],m=h.p,d=i[2];n>3?(o=d===r)&&(c=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=m&&((o=n<2&&m<i[1])?(s=0,h.v=r,h.n=i[1]):m<d&&(o=n<3||i[0]>r||r>d)&&(i[4]=n,i[5]=r,h.n=d,s=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,d){if(u>1)throw TypeError("Generator is already running");for(f&&1===l&&m(l,d),s=l,c=d;(t=s<2?e:c)||!f;){i||(s?s<3?(s>1&&(h.n=-1),m(s,c)):h.n=c:h.v=c);try{if(u=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(f=h.n<0)?c:n.call(r,h))!==a)break}catch(t){i=e,s=1,c=t}finally{u=1}}return{value:t,done:f}}}(n,o,i),!0),l}var a={};function u(){}function l(){}function f(){}t=Object.getPrototypeOf;var h=[][r]?t(t([][r]())):(c(t={},r,function(){return this}),t),m=f.prototype=u.prototype=Object.create(h);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,c(e,o,"GeneratorFunction")),e.prototype=Object.create(m),e}return l.prototype=f,c(m,"constructor",f),c(f,"constructor",l),l.displayName="GeneratorFunction",c(f,o,"GeneratorFunction"),c(m),c(m,o,"Generator"),c(m,r,function(){return this}),c(m,"toString",function(){return"[object Generator]"}),(s=function(){return{w:i,m:d}})()}function c(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}c=function(e,t,n,r){function i(t,n){c(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},c(e,t,n,r)}function a(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}var u=function(){return o(function e(n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i(this,"emitter",void 0),i(this,"url",void 0),i(this,"cmsKey",void 0),i(this,"channel",void 0),i(this,"socket",void 0),i(this,"isConnectionWanted",void 0),i(this,"isConnected",void 0),i(this,"lastMessageAt",void 0),i(this,"interval",void 0),this.emitter={emit:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];for(var o=this.events[e]||[],i=0,s=o.length;i<s;i++)o[i].apply(o,n)},events:{},on:function(e,t){var n,r=this;return((n=this.events)[e]||(n[e]=[])).push(t),function(){var n;r.events[e]=null===(n=r.events[e])||void 0===n?void 0:n.filter(function(e){return t!==e})}}},this.url=null,this.cmsKey=null,this.channel=n,this.isConnected=!1,this.isConnectionWanted=!1,this.lastMessageAt=t.DateTime.now().minus({year:1})},[{key:"on",value:function(e,t){return this.emitter.on(e,t)}},{key:"init",value:(c=r(s().m(function e(){var t=this;return s().w(function(e){for(;;)switch(e.n){case 0:this.interval=setInterval(function(){t.isConnectionWanted&&!t.isActive()&&(console.debug("Xmr::setInterval: should be active"),t.start(t.url||"DISABLED",t.cmsKey||"n/a"))},6e4);case 1:return e.a(2)}},e,this)})),function(){return c.apply(this,arguments)})},{key:"start",value:(n=r(s().m(function e(n,r){var o,i=this;return s().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this.channel&&"unknown"!==this.channel){e.n=1;break}return console.error("Xmr::start: channel unknown, XMR will be disabled"),e.a(2);case 1:if("DISABLED"!==this.url){e.n=2;break}return console.info("Xmr::start: XMR disabled"),this.isConnectionWanted=!1,this.isActive()&&stop(),e.a(2);case 2:if(this.isConnectionWanted=!0,!this.isActive()||this.url!==n){e.n=3;break}return console.debug("Xmr::start: already connected to this URL"),this.cmsKey=r,e.a(2);case 3:if(!this.isConnected){e.n=5;break}return console.debug("Xmr::start: already connected but not active, or a different URL"),e.n=4,this.stop();case 4:e.n=6;break;case 5:console.debug("Xmr::start: not connected yet");case 6:this.url=n,this.cmsKey=r,console.debug("Xmr::start: connecting to "+this.url),e.p=7,this.socket=new WebSocket(this.url),e.n=9;break;case 8:return e.p=8,o=e.v,console.debug("Xmr::start: failed connecting to "+this.url+", e = "+o),this.emitter.emit("error","Failed to connect"),e.a(2);case 9:this.socket.addEventListener("open",function(e){console.debug("Xmr::"+e.type),i.socket.readyState===WebSocket.OPEN?(i.socket.send(JSON.stringify({type:"init",key:i.cmsKey,channel:i.channel})),i.isConnected=!0,i.emitter.emit("connected")):console.info("Xmr::"+e.type+": not open yet")}),this.socket.addEventListener("close",function(e){console.debug("Xmr::"+e.type),i.isConnected=!1,i.emitter.emit("disconnected")}),this.socket.addEventListener("error",function(e){console.debug("Xmr::"+e.type),i.emitter.emit("error","error")}),this.socket.addEventListener("message",function(e){if(console.debug(e),i.lastMessageAt=t.DateTime.now(),i.emitter.emit("statusChange",i.lastMessageAt.toISO()||""),"H"===e.data)console.debug("Xmr::message: Heartbeat...");else{var n=JSON.parse(e.data);console.debug("Xmr::message: action is "+n.action);var r=t.DateTime.fromISO(n.createdDt).plus({seconds:parseInt(n.ttl)});if(r<t.DateTime.now())console.debug("Xmr::message: message expired at "+r.toString());else if("collectNow"===n.action)i.emitter.emit("collectNow");else if("screenShot"===n.action)i.emitter.emit("screenShot");else if("licenceCheck"===n.action)i.emitter.emit("licenceCheck");else if("commandAction"==n.action&&n.commandCode.startsWith("showStatusWindow")){var o=n.commandCode.split("|");i.emitter.emit("showStatusWindow",parseInt(o[1])||60)}else"commandAction"==n.action&&n.commandCode.startsWith("forceUpdateChromeOS")?i.emitter.emit("forceUpdateChromeOS"):console.error("Xmr::message: unknown action: "+n.action)}});case 10:return e.a(2)}},e,this,[[7,8]])})),function(e,t){return n.apply(this,arguments)})},{key:"stop",value:(e=r(s().m(function e(){return s().w(function(e){for(;;)switch(e.n){case 0:console.debug("Xmr::stop"),this.socket&&(console.debug("Xmr::stop: closing active socket"),this.socket.close(),this.isConnected=!1);case 1:return e.a(2)}},e,this)})),function(){return e.apply(this,arguments)})},{key:"isActive",value:function(){return console.debug("Xmr::isActive: lastMessageAt: "+this.lastMessageAt.toString()),this.isConnected&&this.lastMessageAt>t.DateTime.now().minus({minute:15})}}]);var e,n,c}();return e.Xmr=u,e}({},luxon);
|
|
2
4
|
//# sourceMappingURL=xibo-communication-framework.min.js.map
|