@mtgame/core 0.1.156 → 0.2.0
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/bundles/mtgame-core.umd.js +50 -36
- package/bundles/mtgame-core.umd.js.map +1 -1
- package/esm2015/models/basketball-game-config.js +4 -2
- package/esm2015/models/tournament.js +8 -1
- package/esm2015/services/centrifugo.service.js +28 -34
- package/fesm2015/mtgame-core.js +38 -36
- package/fesm2015/mtgame-core.js.map +1 -1
- package/models/basketball-game-config.d.ts +2 -1
- package/models/tournament.d.ts +5 -0
- package/mtgame-core.metadata.json +1 -1
- package/package.json +4 -4
- package/services/centrifugo.service.d.ts +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common/http'), require('rxjs/operators'), require('rxjs'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@mtgame/core', ['exports', '@angular/core', '@angular/common/http', 'rxjs/operators', 'rxjs', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.mtgame = global.mtgame || {}, global.mtgame.core = {}), global.ng.core, global.ng.common.http, global.rxjs.operators, global.rxjs, global.
|
|
5
|
-
}(this, (function (exports, i0, i1, operators, rxjs,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common/http'), require('rxjs/operators'), require('rxjs'), require('centrifuge'), require('rxjs/internal/Subject'), require('@sentry/angular'), require('@angular/forms'), require('@angular/common')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@mtgame/core', ['exports', '@angular/core', '@angular/common/http', 'rxjs/operators', 'rxjs', 'centrifuge', 'rxjs/internal/Subject', '@sentry/angular', '@angular/forms', '@angular/common'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.mtgame = global.mtgame || {}, global.mtgame.core = {}), global.ng.core, global.ng.common.http, global.rxjs.operators, global.rxjs, global.centrifuge, global.rxjs['internal/Subject'], global.angular, global.ng.forms, global.ng.common));
|
|
5
|
+
}(this, (function (exports, i0, i1, operators, rxjs, centrifuge, Subject, angular, forms, common) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopNamespace(e) {
|
|
8
8
|
if (e && e.__esModule) return e;
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
|
|
27
27
|
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
28
28
|
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
29
|
-
var Centrifuge__namespace = /*#__PURE__*/_interopNamespace(Centrifuge);
|
|
30
29
|
|
|
31
30
|
/*! *****************************************************************************
|
|
32
31
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1615,6 +1614,11 @@
|
|
|
1615
1614
|
OvertimeTypes[OvertimeTypes["penalties"] = 8] = "penalties";
|
|
1616
1615
|
OvertimeTypes[OvertimeTypes["time_and_penalties"] = 9] = "time_and_penalties";
|
|
1617
1616
|
})(exports.OvertimeTypes || (exports.OvertimeTypes = {}));
|
|
1617
|
+
exports.TimerTypes = void 0;
|
|
1618
|
+
(function (TimerTypes) {
|
|
1619
|
+
TimerTypes[TimerTypes["backward"] = 1] = "backward";
|
|
1620
|
+
TimerTypes[TimerTypes["forward"] = 2] = "forward";
|
|
1621
|
+
})(exports.TimerTypes || (exports.TimerTypes = {}));
|
|
1618
1622
|
exports.TournamentSettings = /** @class */ (function (_super) {
|
|
1619
1623
|
__extends(TournamentSettings, _super);
|
|
1620
1624
|
function TournamentSettings() {
|
|
@@ -1695,6 +1699,7 @@
|
|
|
1695
1699
|
major_penalty_time: 'majorPenaltyTime',
|
|
1696
1700
|
misconduct_penalty_time: 'misconductPenaltyTime',
|
|
1697
1701
|
game_misconduct_penalty_time: 'gameMisconductPenaltyTime',
|
|
1702
|
+
timer_type: 'timerType',
|
|
1698
1703
|
},
|
|
1699
1704
|
relation: {
|
|
1700
1705
|
type: enumField(exports.TournamentTypes),
|
|
@@ -1704,6 +1709,7 @@
|
|
|
1704
1709
|
rugbyStatisticType: enumField(exports.RugbyStatisticTypes),
|
|
1705
1710
|
gameTimeType: enumField(exports.GameTimeTypes),
|
|
1706
1711
|
overtimeType: enumField(exports.OvertimeTypes),
|
|
1712
|
+
timerType: enumField(exports.TimerTypes),
|
|
1707
1713
|
}
|
|
1708
1714
|
})
|
|
1709
1715
|
], exports.TournamentSettings);
|
|
@@ -1858,11 +1864,13 @@
|
|
|
1858
1864
|
statistic_type: 'statisticType',
|
|
1859
1865
|
shot_clock_enabled: 'shotClockEnabled',
|
|
1860
1866
|
game_time_type: 'gameTimeType',
|
|
1867
|
+
timer_type: 'timerType',
|
|
1861
1868
|
},
|
|
1862
1869
|
relation: {
|
|
1863
1870
|
overtimeType: enumField(exports.OvertimeTypes),
|
|
1864
1871
|
statisticType: enumField(exports.BasketballStatisticTypes),
|
|
1865
1872
|
gameTimeType: enumField(exports.GameTimeTypes),
|
|
1873
|
+
timerType: enumField(exports.TimerTypes),
|
|
1866
1874
|
}
|
|
1867
1875
|
})
|
|
1868
1876
|
], exports.BasketballGameConfig);
|
|
@@ -13151,12 +13159,9 @@
|
|
|
13151
13159
|
if (channel in this.channels$) {
|
|
13152
13160
|
return this.channels$[channel];
|
|
13153
13161
|
}
|
|
13154
|
-
this.channels$[channel] = new
|
|
13155
|
-
|
|
13162
|
+
this.channels$[channel] = new rxjs.Subject();
|
|
13163
|
+
this.connect().subscribe(function (connected) {
|
|
13156
13164
|
_this.subscriptions[channel] = _this.addEngineSubscription(channel);
|
|
13157
|
-
setTimeout(function () {
|
|
13158
|
-
subscription.unsubscribe();
|
|
13159
|
-
});
|
|
13160
13165
|
});
|
|
13161
13166
|
return this.channels$[channel];
|
|
13162
13167
|
};
|
|
@@ -13173,62 +13178,71 @@
|
|
|
13173
13178
|
CentrifugoService.prototype.connect = function () {
|
|
13174
13179
|
var _this = this;
|
|
13175
13180
|
if (!this.initializeEngineSubject) {
|
|
13176
|
-
this.initializeEngineSubject = new
|
|
13177
|
-
this.httpClient.get(this.configService.get('apiUrl') + "/api/v1/
|
|
13181
|
+
this.initializeEngineSubject = new rxjs.ReplaySubject(1);
|
|
13182
|
+
this.httpClient.get(this.configService.get('apiUrl') + "/api/v1/centrifugo_v2/")
|
|
13178
13183
|
.subscribe(function (config) {
|
|
13179
13184
|
_this.initializeEngine({
|
|
13180
13185
|
url: _this.configService.get('centrifugoUrl'),
|
|
13181
|
-
user: config.user,
|
|
13182
|
-
timestamp: config.timestamp,
|
|
13183
13186
|
token: config.token,
|
|
13184
13187
|
transports: ['websocket']
|
|
13185
13188
|
});
|
|
13186
|
-
_this.centrifuge.
|
|
13187
|
-
_this.centrifuge.on('connect', function () {
|
|
13189
|
+
_this.centrifuge.on('connected', function () {
|
|
13188
13190
|
_this.initializeEngineSubject.next(true);
|
|
13189
13191
|
_this.connectedSubject.next(true);
|
|
13190
13192
|
});
|
|
13191
|
-
_this.centrifuge.on('
|
|
13193
|
+
_this.centrifuge.on('disconnected', function () {
|
|
13192
13194
|
_this.connectedSubject.next(false);
|
|
13195
|
+
_this.initializeEngineSubject.next(false);
|
|
13193
13196
|
});
|
|
13197
|
+
_this.centrifuge.connect();
|
|
13194
13198
|
});
|
|
13195
13199
|
}
|
|
13196
|
-
return this.initializeEngineSubject;
|
|
13200
|
+
return this.initializeEngineSubject.pipe(operators.filter(function (item) { return Boolean(item); }), operators.take(1));
|
|
13197
13201
|
};
|
|
13198
13202
|
CentrifugoService.prototype.publish = function (channel, message) {
|
|
13199
13203
|
var _this = this;
|
|
13200
|
-
return
|
|
13201
|
-
_this.connect().subscribe(function () {
|
|
13202
|
-
if (!_this.subscriptions[channel]) {
|
|
13203
|
-
_this.subscriptions[channel] = _this.addEngineSubscription(channel);
|
|
13204
|
-
}
|
|
13205
|
-
_this.subscriptions[channel].publish(message).then(function (res) {
|
|
13206
|
-
observer.next(res);
|
|
13207
|
-
observer.complete();
|
|
13208
|
-
}, function (error) {
|
|
13209
|
-
throw error;
|
|
13210
|
-
});
|
|
13211
|
-
});
|
|
13212
|
-
});
|
|
13204
|
+
return this.connect().pipe(operators.tap(function () { return _this.centrifuge.publish(channel, message); }));
|
|
13213
13205
|
};
|
|
13214
13206
|
CentrifugoService.prototype.disconnect = function () {
|
|
13207
|
+
var e_1, _a;
|
|
13215
13208
|
this.centrifuge.disconnect();
|
|
13216
13209
|
this.initializeEngineSubject = undefined;
|
|
13210
|
+
try {
|
|
13211
|
+
for (var _b = __values(Object.keys(this.channels$)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
13212
|
+
var channel = _c.value;
|
|
13213
|
+
this.unsubscribe(channel);
|
|
13214
|
+
}
|
|
13215
|
+
}
|
|
13216
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
13217
|
+
finally {
|
|
13218
|
+
try {
|
|
13219
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
13220
|
+
}
|
|
13221
|
+
finally { if (e_1) throw e_1.error; }
|
|
13222
|
+
}
|
|
13217
13223
|
this.channels$ = {};
|
|
13218
13224
|
this.subscriptions = {};
|
|
13219
13225
|
};
|
|
13220
13226
|
CentrifugoService.prototype.initializeEngine = function (config) {
|
|
13221
|
-
this.centrifuge = new
|
|
13227
|
+
this.centrifuge = new centrifuge.Centrifuge(config.url, {
|
|
13228
|
+
token: config.token,
|
|
13229
|
+
});
|
|
13222
13230
|
};
|
|
13223
13231
|
CentrifugoService.prototype.addEngineSubscription = function (channel) {
|
|
13224
|
-
|
|
13232
|
+
var _this = this;
|
|
13233
|
+
var sub = this.centrifuge.newSubscription(channel);
|
|
13234
|
+
sub.on('publication', function (ctx) {
|
|
13235
|
+
_this.resolveMessage(channel, ctx.data);
|
|
13236
|
+
});
|
|
13237
|
+
sub.subscribe();
|
|
13238
|
+
return sub;
|
|
13225
13239
|
};
|
|
13226
|
-
CentrifugoService.prototype.resolveMessage = function (
|
|
13227
|
-
var channel = response.channel;
|
|
13240
|
+
CentrifugoService.prototype.resolveMessage = function (channel, message) {
|
|
13228
13241
|
if (!this.channels$[channel]) {
|
|
13229
13242
|
return;
|
|
13230
13243
|
}
|
|
13231
|
-
|
|
13244
|
+
console.log(message);
|
|
13245
|
+
this.channels$[channel].next(message);
|
|
13232
13246
|
};
|
|
13233
13247
|
return CentrifugoService;
|
|
13234
13248
|
}());
|