@jayesol/jayeson.lib.sports 2.2.7-beta → 2.2.7-beta2
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/lib/basketball_codec.d.ts +11 -0
- package/lib/basketball_codec.js +209 -0
- package/lib/client.d.ts +202 -0
- package/lib/client.js +686 -0
- package/lib/codec.d.ts +57 -0
- package/lib/codec.js +129 -0
- package/lib/core.d.ts +159 -0
- package/lib/core.js +497 -0
- package/lib/data_structure.d.ts +113 -0
- package/lib/data_structure.js +208 -0
- package/lib/dispatch.d.ts +126 -0
- package/lib/dispatch.js +324 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +27 -0
- package/lib/merge.d.ts +33 -0
- package/lib/merge.js +569 -0
- package/lib/message_class.d.ts +152 -0
- package/lib/message_class.js +466 -0
- package/lib/module.d.ts +12 -0
- package/lib/module.js +87 -0
- package/lib/mutable.d.ts +118 -0
- package/lib/mutable.js +1061 -0
- package/lib/receive.d.ts +88 -0
- package/lib/receive.js +484 -0
- package/lib/soccer_codec.d.ts +13 -0
- package/lib/soccer_codec.js +168 -0
- package/lib/tennis_codec.d.ts +13 -0
- package/lib/tennis_codec.js +177 -0
- package/package.json +4 -4
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.TTLWrapper = exports.MergeableWrapper = exports.ConvertedMsg = exports.MessageBeforeTransform = exports.DeltaOutgoingImpl = exports.OutgoingImpl = exports.IndexedSnapshotImpl = exports.Incoming = void 0;
|
|
27
|
+
const Collections = __importStar(require("typescript-collections"));
|
|
28
|
+
const jayeson_lib_record_1 = require("@jayesol/jayeson.lib.record");
|
|
29
|
+
class Incoming {
|
|
30
|
+
constructor(_msgType, _stream, _data) {
|
|
31
|
+
this._msgType = _msgType;
|
|
32
|
+
this._stream = _stream;
|
|
33
|
+
this._data = _data;
|
|
34
|
+
}
|
|
35
|
+
msgType() {
|
|
36
|
+
return this._msgType;
|
|
37
|
+
}
|
|
38
|
+
stream() {
|
|
39
|
+
return this._stream;
|
|
40
|
+
}
|
|
41
|
+
data() {
|
|
42
|
+
return this._data;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.Incoming = Incoming;
|
|
46
|
+
class IndexedSnapshotImpl extends jayeson_lib_record_1.Snapshot {
|
|
47
|
+
constructor(matches = {}, partitions = new Collections.Dictionary()) {
|
|
48
|
+
super(matches);
|
|
49
|
+
this.partitions = partitions;
|
|
50
|
+
}
|
|
51
|
+
getPartitions() {
|
|
52
|
+
let keys = new Collections.Set();
|
|
53
|
+
for (var partition of this.partitions.keys()) {
|
|
54
|
+
keys.add(partition);
|
|
55
|
+
}
|
|
56
|
+
return keys;
|
|
57
|
+
}
|
|
58
|
+
//TODO Return Immutable Map/clone??
|
|
59
|
+
getPartitionMap() {
|
|
60
|
+
return this.partitions;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.IndexedSnapshotImpl = IndexedSnapshotImpl;
|
|
64
|
+
IndexedSnapshotImpl.EMPTY_SNAPSHOT = new IndexedSnapshotImpl();
|
|
65
|
+
class OutgoingImpl {
|
|
66
|
+
constructor(_msgType, _msg) {
|
|
67
|
+
this._msgType = _msgType;
|
|
68
|
+
this._msg = _msg;
|
|
69
|
+
}
|
|
70
|
+
msgType() {
|
|
71
|
+
return this._msgType;
|
|
72
|
+
}
|
|
73
|
+
msg() {
|
|
74
|
+
return this._msg;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.OutgoingImpl = OutgoingImpl;
|
|
78
|
+
class DeltaOutgoingImpl extends OutgoingImpl {
|
|
79
|
+
constructor(_msgType, _delta, _after, _before) {
|
|
80
|
+
super(_msgType, _delta);
|
|
81
|
+
this._delta = _delta;
|
|
82
|
+
this._after = _after;
|
|
83
|
+
this._before = _before;
|
|
84
|
+
}
|
|
85
|
+
after() {
|
|
86
|
+
return this._after;
|
|
87
|
+
}
|
|
88
|
+
delta() {
|
|
89
|
+
return this._delta;
|
|
90
|
+
}
|
|
91
|
+
before() {
|
|
92
|
+
return this._before;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.DeltaOutgoingImpl = DeltaOutgoingImpl;
|
|
96
|
+
class MessageBeforeTransform {
|
|
97
|
+
constructor() {
|
|
98
|
+
this.transformEvent = [];
|
|
99
|
+
this.suppressMatch = [];
|
|
100
|
+
this.insertMatch = [];
|
|
101
|
+
this.deleteMatch = [];
|
|
102
|
+
this.insertEvent = [];
|
|
103
|
+
this.deleteEvent = [];
|
|
104
|
+
this.afterSs = IndexedSnapshotImpl.EMPTY_SNAPSHOT;
|
|
105
|
+
this.beforeSs = IndexedSnapshotImpl.EMPTY_SNAPSHOT;
|
|
106
|
+
}
|
|
107
|
+
getTransformEvent() {
|
|
108
|
+
return this.transformEvent;
|
|
109
|
+
}
|
|
110
|
+
setTransformEvent(eventId) {
|
|
111
|
+
this.transformEvent.push(eventId);
|
|
112
|
+
}
|
|
113
|
+
getSuppressMatch() {
|
|
114
|
+
return this.suppressMatch;
|
|
115
|
+
}
|
|
116
|
+
setSuppressMatch(matchId) {
|
|
117
|
+
this.suppressMatch.push(matchId);
|
|
118
|
+
}
|
|
119
|
+
setAfterSs(afterSs) {
|
|
120
|
+
this.afterSs = afterSs;
|
|
121
|
+
}
|
|
122
|
+
getAfterSs() {
|
|
123
|
+
return this.afterSs;
|
|
124
|
+
}
|
|
125
|
+
setBeforeSs(beforeSs) {
|
|
126
|
+
this.beforeSs = beforeSs;
|
|
127
|
+
}
|
|
128
|
+
getBeforeSs() {
|
|
129
|
+
return this.beforeSs;
|
|
130
|
+
}
|
|
131
|
+
setInsertEvent(eventId) {
|
|
132
|
+
this.insertEvent.push(eventId);
|
|
133
|
+
}
|
|
134
|
+
getInsertEvent() {
|
|
135
|
+
return this.insertEvent;
|
|
136
|
+
}
|
|
137
|
+
setDeleteEvent(eventId) {
|
|
138
|
+
this.deleteEvent.push(eventId);
|
|
139
|
+
}
|
|
140
|
+
getDeleteEvent() {
|
|
141
|
+
return this.deleteEvent;
|
|
142
|
+
}
|
|
143
|
+
setInsertMatch(matchId) {
|
|
144
|
+
this.insertMatch.push(matchId);
|
|
145
|
+
}
|
|
146
|
+
getInsertMatch() {
|
|
147
|
+
return this.insertMatch;
|
|
148
|
+
}
|
|
149
|
+
setDeleteMatch(matchId) {
|
|
150
|
+
this.deleteMatch.push(matchId);
|
|
151
|
+
}
|
|
152
|
+
getDeleteMatch() {
|
|
153
|
+
return this.deleteMatch;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.MessageBeforeTransform = MessageBeforeTransform;
|
|
157
|
+
var ConvertedMsg;
|
|
158
|
+
(function (ConvertedMsg) {
|
|
159
|
+
ConvertedMsg[ConvertedMsg["INSERT_EVENT_TO_UPDATE"] = 0] = "INSERT_EVENT_TO_UPDATE";
|
|
160
|
+
ConvertedMsg[ConvertedMsg["DELETE_EVENT_TO_UPDATE"] = 1] = "DELETE_EVENT_TO_UPDATE";
|
|
161
|
+
ConvertedMsg[ConvertedMsg["INSERT_MATCH_SUPPRESS"] = 2] = "INSERT_MATCH_SUPPRESS";
|
|
162
|
+
ConvertedMsg[ConvertedMsg["DELETE_MATCH_SUPPRESS"] = 3] = "DELETE_MATCH_SUPPRESS";
|
|
163
|
+
ConvertedMsg[ConvertedMsg["ORIGINAL"] = 4] = "ORIGINAL";
|
|
164
|
+
})(ConvertedMsg = exports.ConvertedMsg || (exports.ConvertedMsg = {}));
|
|
165
|
+
class MergeableWrapper {
|
|
166
|
+
constructor() {
|
|
167
|
+
this.snap = IndexedSnapshotImpl.EMPTY_SNAPSHOT;
|
|
168
|
+
}
|
|
169
|
+
setDeltaOut(out) {
|
|
170
|
+
this.deltaOut = out;
|
|
171
|
+
}
|
|
172
|
+
setAfter(after) {
|
|
173
|
+
this.snap = after;
|
|
174
|
+
}
|
|
175
|
+
getDeltaOut() {
|
|
176
|
+
return this.deltaOut;
|
|
177
|
+
}
|
|
178
|
+
getAfter() {
|
|
179
|
+
return this.snap;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.MergeableWrapper = MergeableWrapper;
|
|
183
|
+
class TTLWrapper {
|
|
184
|
+
_RemovedKey() {
|
|
185
|
+
this.removedSs = IndexedSnapshotImpl.EMPTY_SNAPSHOT;
|
|
186
|
+
this.remainingSs = IndexedSnapshotImpl.EMPTY_SNAPSHOT;
|
|
187
|
+
this.restoredSs = IndexedSnapshotImpl.EMPTY_SNAPSHOT;
|
|
188
|
+
}
|
|
189
|
+
setRemovedSs(remove) {
|
|
190
|
+
this.removedSs = remove;
|
|
191
|
+
}
|
|
192
|
+
getRemovedSs() {
|
|
193
|
+
return this.removedSs;
|
|
194
|
+
}
|
|
195
|
+
setRemainingSs(remain) {
|
|
196
|
+
this.remainingSs = remain;
|
|
197
|
+
}
|
|
198
|
+
getRemainingSs() {
|
|
199
|
+
return this.remainingSs;
|
|
200
|
+
}
|
|
201
|
+
getRestoredSs() {
|
|
202
|
+
return this.restoredSs;
|
|
203
|
+
}
|
|
204
|
+
setRestoredSs(restore) {
|
|
205
|
+
this.restoredSs = restore;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
exports.TTLWrapper = TTLWrapper;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { DeltaOutgoing, IndexedSnapshot, Outgoing } from "./data_structure";
|
|
2
|
+
import { TTLOutgoing, FSRepo, ISnapshotHandler } from "./core";
|
|
3
|
+
import { SportsFeedMessageGroup } from "./message_class";
|
|
4
|
+
import { InjectionToken } from "injection-js";
|
|
5
|
+
import * as T from 'ts-promise';
|
|
6
|
+
export interface IEndPointGroupManager {
|
|
7
|
+
registerEPD(epd: IEndPointDispatcher): void;
|
|
8
|
+
deregisterEPD(epd: IEndPointDispatcher): void;
|
|
9
|
+
}
|
|
10
|
+
export declare const EPGM_IMPL: InjectionToken<IEndPointGroupManager>;
|
|
11
|
+
export interface IEndPointGroup extends ISnapshotHandler {
|
|
12
|
+
hasEPD(stream: string, id: string): boolean;
|
|
13
|
+
addEPD(epd: IEndPointDispatcher): void;
|
|
14
|
+
removeEPD(epd: IEndPointDispatcher): void;
|
|
15
|
+
isEmpty(): boolean;
|
|
16
|
+
submitForProcess(process: IDispatchableWrapper): void;
|
|
17
|
+
getSportsFeedGrp(): SportsFeedMessageGroup;
|
|
18
|
+
getEPDs(stream: string): IEndPointDispatcher[];
|
|
19
|
+
getStreams(): string[];
|
|
20
|
+
startGetingDeltaSnapshot(fsRepo: FSRepo): void;
|
|
21
|
+
stopGetingDeltaSnapshot(fsRepo: FSRepo): void;
|
|
22
|
+
generateFull(wrapper: FullSnapshotWrapper): Outgoing[];
|
|
23
|
+
generatePartial(wrapper: PartialSnapshotWrapper): Outgoing[];
|
|
24
|
+
}
|
|
25
|
+
export interface IDispatchableWrapper {
|
|
26
|
+
process(): void;
|
|
27
|
+
}
|
|
28
|
+
export declare abstract class WrapperImpl {
|
|
29
|
+
private __epg;
|
|
30
|
+
private __stream;
|
|
31
|
+
constructor(__epg: IEndPointGroup, __stream: string);
|
|
32
|
+
epg(): IEndPointGroup;
|
|
33
|
+
stream(): string;
|
|
34
|
+
}
|
|
35
|
+
export declare class FullSnapshotWrapper extends WrapperImpl implements IDispatchableWrapper {
|
|
36
|
+
private _epg;
|
|
37
|
+
private _stream;
|
|
38
|
+
private _epd;
|
|
39
|
+
fullSnapshot: IndexedSnapshot;
|
|
40
|
+
constructor(_epg: IEndPointGroup, _stream: string, _epd: IEndPointDispatcher, fullSnapshot: IndexedSnapshot);
|
|
41
|
+
epg(): IEndPointGroup;
|
|
42
|
+
stream(): string;
|
|
43
|
+
epd(): IEndPointDispatcher;
|
|
44
|
+
process(): void;
|
|
45
|
+
getFullSnapshot(): IndexedSnapshot;
|
|
46
|
+
setFullSnapshot(fullSnapshot: IndexedSnapshot): void;
|
|
47
|
+
}
|
|
48
|
+
export declare class PartialSnapshotWrapper extends WrapperImpl implements IDispatchableWrapper {
|
|
49
|
+
private _delta;
|
|
50
|
+
private _epg;
|
|
51
|
+
private _stream;
|
|
52
|
+
constructor(_delta: DeltaOutgoing, _epg: IEndPointGroup, _stream: string);
|
|
53
|
+
epg(): IEndPointGroup;
|
|
54
|
+
stream(): string;
|
|
55
|
+
delta(): DeltaOutgoing;
|
|
56
|
+
process(): void;
|
|
57
|
+
}
|
|
58
|
+
export declare class IndicatorWrapper extends WrapperImpl implements IDispatchableWrapper {
|
|
59
|
+
private _delta;
|
|
60
|
+
private _epg;
|
|
61
|
+
private _stream;
|
|
62
|
+
constructor(_delta: Outgoing, _epg: IEndPointGroup, _stream: string);
|
|
63
|
+
process(): void;
|
|
64
|
+
}
|
|
65
|
+
export declare class EPDispatcherException extends Error {
|
|
66
|
+
constructor(message: string);
|
|
67
|
+
}
|
|
68
|
+
export declare class EndPointGroupManager implements IEndPointGroupManager {
|
|
69
|
+
private _fsRepo;
|
|
70
|
+
private _grp;
|
|
71
|
+
relayEPG: RelayEPG;
|
|
72
|
+
constructor(_fsRepo: FSRepo, _grp: SportsFeedMessageGroup);
|
|
73
|
+
fsRepo(): FSRepo;
|
|
74
|
+
grp(): SportsFeedMessageGroup;
|
|
75
|
+
pushFullSnapshotWrapper(epg: IEndPointGroup, epd: IEndPointDispatcher): void;
|
|
76
|
+
registerEPD(epd: IEndPointDispatcher): void;
|
|
77
|
+
deregisterEPD(epd: IEndPointDispatcher): void;
|
|
78
|
+
}
|
|
79
|
+
export interface IEndPointDispatcher {
|
|
80
|
+
id(): string;
|
|
81
|
+
stream(): string;
|
|
82
|
+
submit(out: Outgoing): void;
|
|
83
|
+
onException(e: Error): void;
|
|
84
|
+
isInitialized(): T.Promise<Boolean>;
|
|
85
|
+
readyToDispatch(): void;
|
|
86
|
+
isReadyToDispatch(): boolean;
|
|
87
|
+
}
|
|
88
|
+
export declare class DispatchersGroup {
|
|
89
|
+
private streamName;
|
|
90
|
+
private dispatchers;
|
|
91
|
+
constructor(streamName: string);
|
|
92
|
+
addEpd(epd: IEndPointDispatcher): void;
|
|
93
|
+
removeEpd(epd: IEndPointDispatcher): IEndPointDispatcher;
|
|
94
|
+
get(id: string): IEndPointDispatcher;
|
|
95
|
+
getAll(): IEndPointDispatcher[];
|
|
96
|
+
isEmpty(): boolean;
|
|
97
|
+
}
|
|
98
|
+
export declare abstract class AbstractEPG implements IEndPointGroup {
|
|
99
|
+
private sportsFeedGroup;
|
|
100
|
+
private dispatchers;
|
|
101
|
+
constructor(sportsFeedGroup: SportsFeedMessageGroup);
|
|
102
|
+
hasEPD(stream: string, id: string): boolean;
|
|
103
|
+
addEPD(epd: IEndPointDispatcher): void;
|
|
104
|
+
removeEPD(epd: IEndPointDispatcher): void;
|
|
105
|
+
isEmpty(): boolean;
|
|
106
|
+
abstract submitForProcess(process: IDispatchableWrapper): void;
|
|
107
|
+
getEPDs(stream: string): IEndPointDispatcher[];
|
|
108
|
+
getStreams(): string[];
|
|
109
|
+
startGetingDeltaSnapshot(fsRepo: FSRepo): void;
|
|
110
|
+
stopGetingDeltaSnapshot(fsRepo: FSRepo): void;
|
|
111
|
+
process(stream: string, snapshot: Outgoing): void;
|
|
112
|
+
getSportsFeedGrp(): SportsFeedMessageGroup;
|
|
113
|
+
generateFull(wrapper: FullSnapshotWrapper): Outgoing[];
|
|
114
|
+
generatePartial(wrapper: PartialSnapshotWrapper): Outgoing[];
|
|
115
|
+
}
|
|
116
|
+
export declare class RelayEPG extends AbstractEPG {
|
|
117
|
+
private _sportsFeedGroup;
|
|
118
|
+
constructor(_sportsFeedGroup: SportsFeedMessageGroup);
|
|
119
|
+
submitForProcess(wrapper: IDispatchableWrapper): void;
|
|
120
|
+
onException(e: Error): void;
|
|
121
|
+
generateFull(wrapper: FullSnapshotWrapper): Outgoing[];
|
|
122
|
+
generatePartial(wrapper: PartialSnapshotWrapper): Outgoing[];
|
|
123
|
+
generateTtl(outGng: TTLOutgoing): Outgoing[];
|
|
124
|
+
generateTtlRestore(outGng: TTLOutgoing): Outgoing[];
|
|
125
|
+
private isSameFormat;
|
|
126
|
+
}
|
package/lib/dispatch.js
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RelayEPG = exports.AbstractEPG = exports.DispatchersGroup = exports.EndPointGroupManager = exports.EPDispatcherException = exports.IndicatorWrapper = exports.PartialSnapshotWrapper = exports.FullSnapshotWrapper = exports.WrapperImpl = exports.EPGM_IMPL = void 0;
|
|
16
|
+
const data_structure_1 = require("./data_structure");
|
|
17
|
+
const core_1 = require("./core");
|
|
18
|
+
const message_class_1 = require("./message_class");
|
|
19
|
+
const injection_js_1 = require("injection-js");
|
|
20
|
+
exports.EPGM_IMPL = new injection_js_1.InjectionToken('EpgmInstance');
|
|
21
|
+
class WrapperImpl {
|
|
22
|
+
constructor(__epg, __stream) {
|
|
23
|
+
this.__epg = __epg;
|
|
24
|
+
this.__stream = __stream;
|
|
25
|
+
}
|
|
26
|
+
epg() {
|
|
27
|
+
return this.__epg;
|
|
28
|
+
}
|
|
29
|
+
stream() {
|
|
30
|
+
return this.__stream;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.WrapperImpl = WrapperImpl;
|
|
34
|
+
class FullSnapshotWrapper extends WrapperImpl {
|
|
35
|
+
constructor(_epg, _stream, _epd, fullSnapshot) {
|
|
36
|
+
super(_epg, _stream);
|
|
37
|
+
this._epg = _epg;
|
|
38
|
+
this._stream = _stream;
|
|
39
|
+
this._epd = _epd;
|
|
40
|
+
this.fullSnapshot = fullSnapshot;
|
|
41
|
+
}
|
|
42
|
+
epg() {
|
|
43
|
+
return this._epg;
|
|
44
|
+
}
|
|
45
|
+
stream() {
|
|
46
|
+
return this._stream;
|
|
47
|
+
}
|
|
48
|
+
epd() {
|
|
49
|
+
return this._epd;
|
|
50
|
+
}
|
|
51
|
+
process() {
|
|
52
|
+
this._epd.readyToDispatch();
|
|
53
|
+
let mwList = this._epg.generateFull(this);
|
|
54
|
+
if (mwList != null) {
|
|
55
|
+
for (let i = 0; i < mwList.length; i++) {
|
|
56
|
+
let mw = mwList[i];
|
|
57
|
+
this._epd.submit(mw);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
getFullSnapshot() {
|
|
62
|
+
return this.fullSnapshot;
|
|
63
|
+
}
|
|
64
|
+
setFullSnapshot(fullSnapshot) {
|
|
65
|
+
this.fullSnapshot = fullSnapshot;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.FullSnapshotWrapper = FullSnapshotWrapper;
|
|
69
|
+
class PartialSnapshotWrapper extends WrapperImpl {
|
|
70
|
+
constructor(_delta, _epg, _stream) {
|
|
71
|
+
super(_epg, _stream);
|
|
72
|
+
this._delta = _delta;
|
|
73
|
+
this._epg = _epg;
|
|
74
|
+
this._stream = _stream;
|
|
75
|
+
}
|
|
76
|
+
epg() {
|
|
77
|
+
return this._epg;
|
|
78
|
+
}
|
|
79
|
+
stream() {
|
|
80
|
+
return this._stream;
|
|
81
|
+
}
|
|
82
|
+
delta() {
|
|
83
|
+
return this._delta;
|
|
84
|
+
}
|
|
85
|
+
process() {
|
|
86
|
+
//console.log("the partial snapshot"+JSON.stringify(this.epg.getEPDs(this.stream))+"out going length: "+this.epg.generatePartial(this).length);
|
|
87
|
+
let outgoingList = this._epg.generatePartial(this);
|
|
88
|
+
let epds = this._epg.getEPDs(this._stream);
|
|
89
|
+
for (let i = 0; i < epds.length; i++) {
|
|
90
|
+
let epd = epds[i];
|
|
91
|
+
for (let j = 0; j < outgoingList.length; j++) {
|
|
92
|
+
if (epd.isReadyToDispatch()) {
|
|
93
|
+
let out = outgoingList[j];
|
|
94
|
+
epd.submit(out);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.PartialSnapshotWrapper = PartialSnapshotWrapper;
|
|
101
|
+
class IndicatorWrapper extends WrapperImpl {
|
|
102
|
+
constructor(_delta, _epg, _stream) {
|
|
103
|
+
super(_epg, _stream);
|
|
104
|
+
this._delta = _delta;
|
|
105
|
+
this._epg = _epg;
|
|
106
|
+
this._stream = _stream;
|
|
107
|
+
}
|
|
108
|
+
process() {
|
|
109
|
+
let epds = this._epg.getEPDs(this._stream);
|
|
110
|
+
for (let i = 0; i < epds.length; i++) {
|
|
111
|
+
let epd = epds[i];
|
|
112
|
+
epd.submit(this._delta);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.IndicatorWrapper = IndicatorWrapper;
|
|
117
|
+
class EPDispatcherException extends Error {
|
|
118
|
+
constructor(message) {
|
|
119
|
+
super(message);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.EPDispatcherException = EPDispatcherException;
|
|
123
|
+
let EndPointGroupManager = class EndPointGroupManager {
|
|
124
|
+
constructor(_fsRepo, _grp) {
|
|
125
|
+
this._fsRepo = _fsRepo;
|
|
126
|
+
this._grp = _grp;
|
|
127
|
+
this.relayEPG = new RelayEPG(_grp);
|
|
128
|
+
this.relayEPG.startGetingDeltaSnapshot(_fsRepo);
|
|
129
|
+
}
|
|
130
|
+
fsRepo() {
|
|
131
|
+
return this._fsRepo;
|
|
132
|
+
}
|
|
133
|
+
grp() {
|
|
134
|
+
return this._grp;
|
|
135
|
+
}
|
|
136
|
+
pushFullSnapshotWrapper(epg, epd) {
|
|
137
|
+
let stream = epd.stream();
|
|
138
|
+
epd.isInitialized().then((ready) => {
|
|
139
|
+
if (ready) {
|
|
140
|
+
let rawSnapshot = this._fsRepo.getSnapshot(stream);
|
|
141
|
+
let sw = new FullSnapshotWrapper(epg, stream, epd, rawSnapshot);
|
|
142
|
+
epg.submitForProcess(sw);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
registerEPD(epd) {
|
|
147
|
+
if (this.relayEPG.hasEPD(epd.stream(), epd.id())) {
|
|
148
|
+
throw new EPDispatcherException("EPD already exists in a group.Id: " + epd.id + " Stream: " + epd.stream);
|
|
149
|
+
}
|
|
150
|
+
this.relayEPG.addEPD(epd);
|
|
151
|
+
this.pushFullSnapshotWrapper(this.relayEPG, epd);
|
|
152
|
+
}
|
|
153
|
+
deregisterEPD(epd) {
|
|
154
|
+
// Clean up EPD
|
|
155
|
+
this.relayEPG.removeEPD(epd);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
EndPointGroupManager = __decorate([
|
|
159
|
+
(0, injection_js_1.Injectable)(),
|
|
160
|
+
__param(0, (0, injection_js_1.Inject)(core_1.FSREPO_IMPL)),
|
|
161
|
+
__metadata("design:paramtypes", [Object, message_class_1.SportsFeedMessageGroup])
|
|
162
|
+
], EndPointGroupManager);
|
|
163
|
+
exports.EndPointGroupManager = EndPointGroupManager;
|
|
164
|
+
class DispatchersGroup {
|
|
165
|
+
constructor(streamName) {
|
|
166
|
+
this.streamName = streamName;
|
|
167
|
+
this.dispatchers = {};
|
|
168
|
+
}
|
|
169
|
+
addEpd(epd) {
|
|
170
|
+
this.dispatchers[epd.id()] = epd;
|
|
171
|
+
}
|
|
172
|
+
removeEpd(epd) {
|
|
173
|
+
let current = this.dispatchers[epd.id()];
|
|
174
|
+
delete this.dispatchers[epd.id()];
|
|
175
|
+
return current;
|
|
176
|
+
}
|
|
177
|
+
get(id) {
|
|
178
|
+
return this.dispatchers[id];
|
|
179
|
+
}
|
|
180
|
+
getAll() {
|
|
181
|
+
return Object.keys(this.dispatchers).map((k) => {
|
|
182
|
+
return this.dispatchers[k];
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
isEmpty() {
|
|
186
|
+
return Object.keys(this.dispatchers).length == 0;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
exports.DispatchersGroup = DispatchersGroup;
|
|
190
|
+
class AbstractEPG {
|
|
191
|
+
constructor(sportsFeedGroup) {
|
|
192
|
+
this.sportsFeedGroup = sportsFeedGroup;
|
|
193
|
+
this.dispatchers = {};
|
|
194
|
+
}
|
|
195
|
+
hasEPD(stream, id) {
|
|
196
|
+
let dGrp = this.dispatchers[stream];
|
|
197
|
+
if (dGrp !== undefined) {
|
|
198
|
+
return dGrp.get(id) !== undefined;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
addEPD(epd) {
|
|
205
|
+
let grp = this.dispatchers[epd.stream()];
|
|
206
|
+
if (grp === undefined) {
|
|
207
|
+
this.dispatchers[epd.stream()] = new DispatchersGroup(epd.stream());
|
|
208
|
+
}
|
|
209
|
+
this.dispatchers[epd.stream()].addEpd(epd);
|
|
210
|
+
}
|
|
211
|
+
removeEPD(epd) {
|
|
212
|
+
let grp = this.dispatchers[epd.stream()];
|
|
213
|
+
if (grp !== undefined) {
|
|
214
|
+
grp.removeEpd(epd);
|
|
215
|
+
if (grp.isEmpty()) {
|
|
216
|
+
delete this.dispatchers[epd.stream()];
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
isEmpty() {
|
|
221
|
+
return Object.keys(this.dispatchers).length == 0;
|
|
222
|
+
}
|
|
223
|
+
getEPDs(stream) {
|
|
224
|
+
let dGrp = this.dispatchers[stream];
|
|
225
|
+
if (dGrp !== undefined) {
|
|
226
|
+
return dGrp.getAll();
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
return [];
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
getStreams() {
|
|
233
|
+
return Object.keys(this.dispatchers);
|
|
234
|
+
}
|
|
235
|
+
startGetingDeltaSnapshot(fsRepo) {
|
|
236
|
+
fsRepo.registerSnapshotHandler(this);
|
|
237
|
+
}
|
|
238
|
+
stopGetingDeltaSnapshot(fsRepo) {
|
|
239
|
+
fsRepo.deRegisterSnapshotHandler(this);
|
|
240
|
+
}
|
|
241
|
+
process(stream, snapshot) {
|
|
242
|
+
if (this.sportsFeedGroup.isIndicatorMessage(snapshot.msgType())) {
|
|
243
|
+
let filterIndicatorWrapper = new IndicatorWrapper(snapshot, this, stream);
|
|
244
|
+
this.submitForProcess(filterIndicatorWrapper);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
let partWrapper = new PartialSnapshotWrapper(snapshot, this, stream);
|
|
248
|
+
this.submitForProcess(partWrapper);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
getSportsFeedGrp() {
|
|
252
|
+
return this.sportsFeedGroup;
|
|
253
|
+
}
|
|
254
|
+
generateFull(wrapper) {
|
|
255
|
+
throw new Error("Method not implemented.");
|
|
256
|
+
}
|
|
257
|
+
generatePartial(wrapper) {
|
|
258
|
+
throw new Error("Method not implemented.");
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
exports.AbstractEPG = AbstractEPG;
|
|
262
|
+
let RelayEPG = class RelayEPG extends AbstractEPG {
|
|
263
|
+
constructor(_sportsFeedGroup) {
|
|
264
|
+
super(_sportsFeedGroup);
|
|
265
|
+
this._sportsFeedGroup = _sportsFeedGroup;
|
|
266
|
+
}
|
|
267
|
+
submitForProcess(wrapper) {
|
|
268
|
+
wrapper.process();
|
|
269
|
+
}
|
|
270
|
+
onException(e) {
|
|
271
|
+
console.error("Exception when dispatching snapshots to EPDs from RelayEPG. ", e);
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
generateFull(wrapper) {
|
|
275
|
+
let ss = wrapper.getFullSnapshot();
|
|
276
|
+
let fssStart = new data_structure_1.OutgoingImpl(this._sportsFeedGroup.FULLSNAPSHOT_START(), new Object());
|
|
277
|
+
let reset = new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_RESET(), ss, ss, data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT);
|
|
278
|
+
let insertMatch = new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_MATCH(), ss, ss, data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT);
|
|
279
|
+
let insertEvent = new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_EVENT(), ss, ss, data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT);
|
|
280
|
+
let insertRecord = new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_ODD(), ss, ss, data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT);
|
|
281
|
+
let fssEnd = new data_structure_1.OutgoingImpl(this._sportsFeedGroup.FULLSNAPSHOT_END(), new Object());
|
|
282
|
+
return [fssStart, reset, insertMatch, insertEvent, insertRecord, fssEnd];
|
|
283
|
+
}
|
|
284
|
+
generatePartial(wrapper) {
|
|
285
|
+
let delta = wrapper.delta();
|
|
286
|
+
if (delta.constructor.name == "TTLOutgoing") {
|
|
287
|
+
return this.generateTtl(delta);
|
|
288
|
+
}
|
|
289
|
+
return [delta];
|
|
290
|
+
}
|
|
291
|
+
generateTtl(outGng) {
|
|
292
|
+
// Return if Message Type is Refresh
|
|
293
|
+
if (this.isSameFormat(outGng.msgType(), this._sportsFeedGroup.ADMIN_REFRESH())) {
|
|
294
|
+
return [];
|
|
295
|
+
}
|
|
296
|
+
let ttlType = outGng.getTtlType();
|
|
297
|
+
if (ttlType == core_1.TTLType.REMOVE) {
|
|
298
|
+
// Process Remove Message as Normal Partial Message
|
|
299
|
+
return [outGng];
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
return this.generateTtlRestore(outGng);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
generateTtlRestore(outGng) {
|
|
306
|
+
let insertMatch = new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_MATCH(), outGng.delta(), outGng.delta(), data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT);
|
|
307
|
+
let insertEvent = new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_EVENT(), outGng.delta(), outGng.delta(), data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT);
|
|
308
|
+
let insertRecord = new data_structure_1.DeltaOutgoingImpl(this._sportsFeedGroup.DATA_INSERT_ODD(), outGng.delta(), outGng.delta(), data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT);
|
|
309
|
+
return [insertMatch, insertEvent, insertRecord];
|
|
310
|
+
}
|
|
311
|
+
isSameFormat(lhs, messageClass) {
|
|
312
|
+
if (lhs.instanceClass() == messageClass.instanceClass() && lhs.constructor.name == messageClass.constructor.name) {
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
RelayEPG = __decorate([
|
|
321
|
+
(0, injection_js_1.Injectable)(),
|
|
322
|
+
__metadata("design:paramtypes", [message_class_1.SportsFeedMessageGroup])
|
|
323
|
+
], RelayEPG);
|
|
324
|
+
exports.RelayEPG = RelayEPG;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./basketball_codec";
|
|
2
|
+
export * from "./client";
|
|
3
|
+
export * from "./codec";
|
|
4
|
+
export * from "./core";
|
|
5
|
+
export * from "./data_structure";
|
|
6
|
+
export * from "./dispatch";
|
|
7
|
+
export * from "./message_class";
|
|
8
|
+
export * from "./module";
|
|
9
|
+
export * from "./receive";
|
|
10
|
+
export * from "./soccer_codec";
|
|
11
|
+
export * from "./tennis_codec";
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./basketball_codec"), exports);
|
|
18
|
+
__exportStar(require("./client"), exports);
|
|
19
|
+
__exportStar(require("./codec"), exports);
|
|
20
|
+
__exportStar(require("./core"), exports);
|
|
21
|
+
__exportStar(require("./data_structure"), exports);
|
|
22
|
+
__exportStar(require("./dispatch"), exports);
|
|
23
|
+
__exportStar(require("./message_class"), exports);
|
|
24
|
+
__exportStar(require("./module"), exports);
|
|
25
|
+
__exportStar(require("./receive"), exports);
|
|
26
|
+
__exportStar(require("./soccer_codec"), exports);
|
|
27
|
+
__exportStar(require("./tennis_codec"), exports);
|