@genesislcap/foundation-comms 14.167.2 → 14.167.3-alpha-b40d1e5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/dts/auth/auth.d.ts.map +1 -1
- package/dist/dts/connect/connect.d.ts +11 -1
- package/dist/dts/connect/connect.d.ts.map +1 -1
- package/dist/dts/connect/connect.events.d.ts +173 -0
- package/dist/dts/connect/connect.events.d.ts.map +1 -0
- package/dist/dts/connect/http.connect.d.ts +1 -0
- package/dist/dts/connect/http.connect.d.ts.map +1 -1
- package/dist/dts/connect/index.d.ts +2 -0
- package/dist/dts/connect/index.d.ts.map +1 -1
- package/dist/dts/connect/message.d.ts +51 -0
- package/dist/dts/connect/message.d.ts.map +1 -1
- package/dist/dts/connect/socket.d.ts +72 -8
- package/dist/dts/connect/socket.d.ts.map +1 -1
- package/dist/dts/connect/socket.status.d.ts +79 -0
- package/dist/dts/connect/socket.status.d.ts.map +1 -0
- package/dist/dts/datasource/datasource.d.ts +9 -0
- package/dist/dts/datasource/datasource.d.ts.map +1 -1
- package/dist/dts/fdc3/fdc3.d.ts +17 -1
- package/dist/dts/fdc3/fdc3.d.ts.map +1 -1
- package/dist/dts/index.d.ts +1 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/networkMonitor/config.d.ts +56 -0
- package/dist/dts/networkMonitor/config.d.ts.map +1 -0
- package/dist/dts/networkMonitor/index.d.ts +4 -0
- package/dist/dts/networkMonitor/index.d.ts.map +1 -0
- package/dist/dts/networkMonitor/service.d.ts +193 -0
- package/dist/dts/networkMonitor/service.d.ts.map +1 -0
- package/dist/dts/networkMonitor/types.d.ts +133 -0
- package/dist/dts/networkMonitor/types.d.ts.map +1 -0
- package/dist/dts/testing/mocks/connect/connect.d.ts +1 -0
- package/dist/dts/testing/mocks/connect/connect.d.ts.map +1 -1
- package/dist/dts/testing/mocks/connect/socket.d.ts +5 -1
- package/dist/dts/testing/mocks/connect/socket.d.ts.map +1 -1
- package/dist/dts/testing/mocks/datasource/datasource.d.ts +1 -0
- package/dist/dts/testing/mocks/datasource/datasource.d.ts.map +1 -1
- package/dist/dts/user/user.d.ts +15 -0
- package/dist/dts/user/user.d.ts.map +1 -1
- package/dist/esm/auth/auth.js +5 -2
- package/dist/esm/connect/connect.events.js +113 -0
- package/dist/esm/connect/connect.js +30 -8
- package/dist/esm/connect/http.connect.js +6 -0
- package/dist/esm/connect/index.js +2 -0
- package/dist/esm/connect/message.js +25 -4
- package/dist/esm/connect/socket.js +113 -44
- package/dist/esm/connect/socket.status.js +119 -0
- package/dist/esm/datasource/datasource.js +18 -8
- package/dist/esm/fdc3/fdc3.js +4 -4
- package/dist/esm/index.js +1 -0
- package/dist/esm/networkMonitor/config.js +46 -0
- package/dist/esm/networkMonitor/index.js +3 -0
- package/dist/esm/networkMonitor/service.js +432 -0
- package/dist/esm/networkMonitor/types.js +5 -0
- package/dist/esm/testing/mocks/connect/connect.js +3 -0
- package/dist/esm/testing/mocks/connect/socket.js +1 -1
- package/dist/esm/testing/mocks/datasource/datasource.js +1 -0
- package/dist/esm/user/user.js +22 -1
- package/dist/foundation-comms.api.json +14711 -8166
- package/dist/foundation-comms.d.ts +841 -13
- package/docs/api/foundation-comms.commitevent.md +14 -0
- package/docs/api/foundation-comms.commiteventdetail.md +17 -0
- package/docs/api/foundation-comms.commiteventtype.md +12 -0
- package/docs/api/foundation-comms.connect.getmorecolumns.md +26 -0
- package/docs/api/foundation-comms.connect.md +1 -0
- package/docs/api/foundation-comms.connectevents.addcommitlistener.md +24 -0
- package/docs/api/foundation-comms.connectevents.addmetadatalistener.md +24 -0
- package/docs/api/foundation-comms.connectevents.addstreamlistener.md +25 -0
- package/docs/api/foundation-comms.connectevents.md +22 -0
- package/docs/api/foundation-comms.connecteventsemitter.md +24 -0
- package/docs/api/foundation-comms.connecteventsemitter.oncommitevent.md +25 -0
- package/docs/api/foundation-comms.connecteventsemitter.onmetadataevent.md +26 -0
- package/docs/api/foundation-comms.connecteventsemitter.onstreamcompleteevent.md +24 -0
- package/docs/api/foundation-comms.connecteventsemitter.onstreamevent.md +27 -0
- package/docs/api/foundation-comms.currentuser.md +2 -0
- package/docs/api/foundation-comms.currentuser.set.md +22 -0
- package/docs/api/foundation-comms.currentuser.unset.md +15 -0
- package/docs/api/foundation-comms.datasource.destroy.md +17 -0
- package/docs/api/foundation-comms.datasource.md +1 -0
- package/docs/api/foundation-comms.defaultconnect._constructor_.md +2 -1
- package/docs/api/foundation-comms.defaultconnect.getmorecolumns.md +22 -0
- package/docs/api/foundation-comms.defaultconnect.md +2 -1
- package/docs/api/foundation-comms.defaultconnectevents.addcommitlistener.md +24 -0
- package/docs/api/foundation-comms.defaultconnectevents.addmetadatalistener.md +24 -0
- package/docs/api/foundation-comms.defaultconnectevents.addstreamlistener.md +25 -0
- package/docs/api/foundation-comms.defaultconnectevents.md +27 -0
- package/docs/api/foundation-comms.defaultconnectevents.oncommitevent.md +25 -0
- package/docs/api/foundation-comms.defaultconnectevents.onmetadataevent.md +26 -0
- package/docs/api/foundation-comms.defaultconnectevents.onstreamcompleteevent.md +24 -0
- package/docs/api/foundation-comms.defaultconnectevents.onstreamevent.md +27 -0
- package/docs/api/foundation-comms.defaultdatasource.destroy.md +17 -0
- package/docs/api/foundation-comms.defaultdatasource.md +1 -0
- package/docs/api/foundation-comms.defaulthttpconnect.getmorecolumns.md +22 -0
- package/docs/api/foundation-comms.defaulthttpconnect.md +1 -0
- package/docs/api/foundation-comms.defaultmessagebuilder._constructor_.md +21 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createchangepasswordmessage.md +24 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createcommitmessage.md +23 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createdatalogoffmessage.md +22 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createdatalogonmessage.md +23 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createforgotpasswordmessage.md +24 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createforgotpasswordtokenmessage.md +25 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createhttpheadersfrommessage.md +23 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createloginmessage.md +22 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createlogoutmessage.md +22 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createmetarequestmessage.md +23 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createmorecolumnsmessage.md +22 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createmorerowsmessage.md +22 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createrefreshtokenmessage.md +15 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createrequestmessage.md +23 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.createresourcesmessage.md +22 -0
- package/docs/api/foundation-comms.defaultmessagebuilder.md +41 -0
- package/docs/api/foundation-comms.defaultnetworkmonitor.addresource.md +23 -0
- package/docs/api/foundation-comms.defaultnetworkmonitor.create.md +16 -0
- package/docs/api/foundation-comms.defaultnetworkmonitor.destroy.md +16 -0
- package/docs/api/foundation-comms.defaultnetworkmonitor.md +31 -0
- package/docs/api/foundation-comms.defaultnetworkmonitor.removeresource.md +22 -0
- package/docs/api/foundation-comms.defaultnetworkmonitor.runallchecks.md +11 -0
- package/docs/api/foundation-comms.defaultnetworkmonitor.status.md +12 -0
- package/docs/api/foundation-comms.defaultnetworkmonitorconfig.md +13 -0
- package/docs/api/foundation-comms.defaultsocket._constructor_.md +24 -0
- package/docs/api/foundation-comms.defaultsocket.connect.md +24 -0
- package/docs/api/foundation-comms.defaultsocket.hasvalidsession.md +13 -0
- package/docs/api/foundation-comms.defaultsocket.isconfigured.md +11 -0
- package/docs/api/foundation-comms.defaultsocket.isconnected.md +11 -0
- package/docs/api/foundation-comms.defaultsocket.isconnectedsubject.md +11 -0
- package/docs/api/foundation-comms.defaultsocket.isconnecting.md +11 -0
- package/docs/api/foundation-comms.defaultsocket.isdisconnected.md +11 -0
- package/docs/api/foundation-comms.defaultsocket.isdisconnectedbyserver.md +11 -0
- package/docs/api/foundation-comms.defaultsocket.isreconnecting.md +11 -0
- package/docs/api/foundation-comms.defaultsocket.md +44 -0
- package/docs/api/foundation-comms.defaultsocket.reset.md +15 -0
- package/docs/api/foundation-comms.defaultsocket.send.md +23 -0
- package/docs/api/foundation-comms.defaultsocket.sendforstream.md +25 -0
- package/docs/api/foundation-comms.defaultsocket.socketmessages.md +11 -0
- package/docs/api/foundation-comms.defaultsocketstatus.closedclean.md +11 -0
- package/docs/api/foundation-comms.defaultsocketstatus.closedcode.md +11 -0
- package/docs/api/foundation-comms.defaultsocketstatus.closedreason.md +11 -0
- package/docs/api/foundation-comms.defaultsocketstatus.hasvalidsession.md +11 -0
- package/docs/api/foundation-comms.defaultsocketstatus.isconfigured.md +11 -0
- package/docs/api/foundation-comms.defaultsocketstatus.isconnected.md +11 -0
- package/docs/api/foundation-comms.defaultsocketstatus.isconnectedchanged.md +15 -0
- package/docs/api/foundation-comms.defaultsocketstatus.isconnectedsubject.md +11 -0
- package/docs/api/foundation-comms.defaultsocketstatus.isconnecting.md +11 -0
- package/docs/api/foundation-comms.defaultsocketstatus.isdisconnected.md +11 -0
- package/docs/api/foundation-comms.defaultsocketstatus.isdisconnectedbyserver.md +11 -0
- package/docs/api/foundation-comms.defaultsocketstatus.isreconnecting.md +11 -0
- package/docs/api/foundation-comms.defaultsocketstatus.isreconnectingchanged.md +15 -0
- package/docs/api/foundation-comms.defaultsocketstatus.md +42 -0
- package/docs/api/foundation-comms.defaultsocketstatus.onclose.md +22 -0
- package/docs/api/foundation-comms.defaultsocketstatus.reconnectionlimitreached.md +11 -0
- package/docs/api/foundation-comms.defaultsocketstatus.resetclosedstate.md +15 -0
- package/docs/api/foundation-comms.defaultsocketstatus.serialize.md +15 -0
- package/docs/api/foundation-comms.genesisconnectevents.md +18 -0
- package/docs/api/foundation-comms.getnetworkmonitor.md +30 -0
- package/docs/api/foundation-comms.getsocket.md +30 -0
- package/docs/api/foundation-comms.getsocketstatus.md +30 -0
- package/docs/api/foundation-comms.md +39 -0
- package/docs/api/foundation-comms.messagebuilder.createmorecolumnsmessage.md +30 -0
- package/docs/api/foundation-comms.messagebuilder.md +1 -0
- package/docs/api/foundation-comms.messagehaserrorcode.md +13 -0
- package/docs/api/foundation-comms.messagetype.md +2 -0
- package/docs/api/foundation-comms.metadataevent.md +14 -0
- package/docs/api/foundation-comms.metadataeventdetail.md +18 -0
- package/docs/api/foundation-comms.metadataeventtype.md +12 -0
- package/docs/api/foundation-comms.monitoredresource.md +15 -0
- package/docs/api/foundation-comms.monitoredresourcechecks.md +15 -0
- package/docs/api/foundation-comms.monitoredresourcechecksresult.isconnected.md +11 -0
- package/docs/api/foundation-comms.monitoredresourcechecksresult.lastmessage.md +11 -0
- package/docs/api/foundation-comms.monitoredresourcechecksresult.lastupdated.md +11 -0
- package/docs/api/foundation-comms.monitoredresourcechecksresult.md +23 -0
- package/docs/api/foundation-comms.monitoredresourcechecksresult.timeout.md +11 -0
- package/docs/api/foundation-comms.monitoredresourcedatalogon.md +15 -0
- package/docs/api/foundation-comms.monitoredresourcemetadata.md +15 -0
- package/docs/api/foundation-comms.networklogger.md +12 -0
- package/docs/api/foundation-comms.networkmonitor.addresource.md +23 -0
- package/docs/api/foundation-comms.networkmonitor.create.md +15 -0
- package/docs/api/foundation-comms.networkmonitor.destroy.md +15 -0
- package/docs/api/foundation-comms.networkmonitor.md +34 -0
- package/docs/api/foundation-comms.networkmonitor.removeresource.md +22 -0
- package/docs/api/foundation-comms.networkmonitor.runallchecks.md +23 -0
- package/docs/api/foundation-comms.networkmonitor.status.md +11 -0
- package/docs/api/foundation-comms.networkmonitorconfig.checkinterval.md +13 -0
- package/docs/api/foundation-comms.networkmonitorconfig.checktimeout.md +13 -0
- package/docs/api/foundation-comms.networkmonitorconfig.documentevents.md +13 -0
- package/docs/api/foundation-comms.networkmonitorconfig.eventemitter.md +13 -0
- package/docs/api/foundation-comms.networkmonitorconfig.genesisconnectevents.md +13 -0
- package/docs/api/foundation-comms.networkmonitorconfig.md +27 -0
- package/docs/api/foundation-comms.networkmonitorconfig.resourcechecks.md +13 -0
- package/docs/api/foundation-comms.networkmonitorconfig.resourcedatalogon.md +18 -0
- package/docs/api/foundation-comms.networkmonitorconfig.windowevents.md +13 -0
- package/docs/api/foundation-comms.resourcehealth.md +19 -0
- package/docs/api/foundation-comms.serializedsocketstatus.closedclean.md +11 -0
- package/docs/api/foundation-comms.serializedsocketstatus.closedcode.md +11 -0
- package/docs/api/foundation-comms.serializedsocketstatus.closedreason.md +11 -0
- package/docs/api/foundation-comms.serializedsocketstatus.hasvalidsession.md +11 -0
- package/docs/api/foundation-comms.serializedsocketstatus.isconfigured.md +13 -0
- package/docs/api/foundation-comms.serializedsocketstatus.isconnected.md +11 -0
- package/docs/api/foundation-comms.serializedsocketstatus.isconnecting.md +11 -0
- package/docs/api/foundation-comms.serializedsocketstatus.isdisconnected.md +11 -0
- package/docs/api/foundation-comms.serializedsocketstatus.isdisconnectedbyserver.md +11 -0
- package/docs/api/foundation-comms.serializedsocketstatus.isreconnecting.md +11 -0
- package/docs/api/foundation-comms.serializedsocketstatus.md +30 -0
- package/docs/api/foundation-comms.serializedsocketstatus.reconnectionlimitreached.md +11 -0
- package/docs/api/foundation-comms.socket.md +3 -11
- package/docs/api/foundation-comms.socket.sendforstream.md +2 -1
- package/docs/api/{foundation-comms.socket.isconnectedsubject.md → foundation-comms.socketstatus.isconnectedsubject.md} +2 -2
- package/docs/api/foundation-comms.socketstatus.md +28 -0
- package/docs/api/foundation-comms.socketstatus.onclose.md +22 -0
- package/docs/api/foundation-comms.socketstatus.serialize.md +15 -0
- package/docs/api/foundation-comms.streamcompleteevent.md +14 -0
- package/docs/api/foundation-comms.streamcompleteeventtype.md +12 -0
- package/docs/api/foundation-comms.streamevent.md +14 -0
- package/docs/api/foundation-comms.streameventdetail.md +19 -0
- package/docs/api/foundation-comms.streameventfunctions.md +19 -0
- package/docs/api/foundation-comms.streameventtype.md +12 -0
- package/docs/api/foundation-comms.systemhealthchanged.md +13 -0
- package/docs/api/foundation-comms.systemhealthchangedevent.md +15 -0
- package/docs/api/foundation-comms.systemhealthstatus.md +29 -0
- package/docs/api/foundation-comms.user.md +2 -0
- package/docs/api/foundation-comms.user.set.md +22 -0
- package/docs/api/foundation-comms.user.unset.md +15 -0
- package/docs/api-report.md +520 -16
- package/package.json +13 -11
- package/docs/api/foundation-comms.socket.hasvalidsession.md +0 -11
- package/docs/api/foundation-comms.socket.isconnected.md +0 -11
- package/docs/api/foundation-comms.socket.isreconnecting.md +0 -11
@@ -0,0 +1,113 @@
|
|
1
|
+
import { createObserver } from '@genesislcap/foundation-utils';
|
2
|
+
import { DI } from '@microsoft/fast-foundation';
|
3
|
+
/**
|
4
|
+
* @public
|
5
|
+
*/
|
6
|
+
export const CommitEventType = 'connect-commit-event';
|
7
|
+
/**
|
8
|
+
* @public
|
9
|
+
*/
|
10
|
+
export const StreamEventType = 'connect-stream-event';
|
11
|
+
/**
|
12
|
+
* @public
|
13
|
+
*/
|
14
|
+
export const StreamCompleteEventType = 'connect-stream-complete-event';
|
15
|
+
/**
|
16
|
+
* @public
|
17
|
+
*/
|
18
|
+
export const MetadataEventType = 'connect-metadata-event';
|
19
|
+
/**
|
20
|
+
* Default ConnectEvents implementation.
|
21
|
+
* @public
|
22
|
+
*/
|
23
|
+
export class DefaultConnectEvents {
|
24
|
+
constructor() {
|
25
|
+
/** @internal */
|
26
|
+
this.streamListeners = createObserver();
|
27
|
+
/** @internal */
|
28
|
+
this.streamCompleteListeners = createObserver();
|
29
|
+
/** @internal */
|
30
|
+
this.commitListeners = createObserver();
|
31
|
+
/** @internal */
|
32
|
+
this.metadataListeners = createObserver();
|
33
|
+
}
|
34
|
+
/** {@inheritDoc ConnectEvents.addStreamListener} */
|
35
|
+
addStreamListener(listener, complete) {
|
36
|
+
var _a, _b;
|
37
|
+
const unsubscribe = (_a = this.streamListeners) === null || _a === void 0 ? void 0 : _a.subscribe(listener);
|
38
|
+
const completeUnsubscribe = (_b = this.streamCompleteListeners) === null || _b === void 0 ? void 0 : _b.subscribe(complete);
|
39
|
+
return () => {
|
40
|
+
unsubscribe();
|
41
|
+
completeUnsubscribe();
|
42
|
+
};
|
43
|
+
}
|
44
|
+
/** {@inheritDoc ConnectEventsEmitter.onStreamEvent} */
|
45
|
+
onStreamEvent(resourceName, message, stream, functions) {
|
46
|
+
var _a;
|
47
|
+
(_a = this.streamListeners) === null || _a === void 0 ? void 0 : _a.publish(new CustomEvent(StreamEventType, {
|
48
|
+
detail: {
|
49
|
+
functions,
|
50
|
+
message,
|
51
|
+
resourceName,
|
52
|
+
stream,
|
53
|
+
},
|
54
|
+
}));
|
55
|
+
}
|
56
|
+
/** {@inheritDoc ConnectEventsEmitter.onStreamCompleteEvent} */
|
57
|
+
onStreamCompleteEvent(stream) {
|
58
|
+
var _a;
|
59
|
+
(_a = this.streamCompleteListeners) === null || _a === void 0 ? void 0 : _a.publish(new CustomEvent(StreamCompleteEventType, {
|
60
|
+
detail: stream,
|
61
|
+
}));
|
62
|
+
}
|
63
|
+
/** {@inheritDoc ConnectEvents.addCommitListener} */
|
64
|
+
addCommitListener(listener) {
|
65
|
+
var _a;
|
66
|
+
return (_a = this.commitListeners) === null || _a === void 0 ? void 0 : _a.subscribe(listener);
|
67
|
+
}
|
68
|
+
/** {@inheritDoc ConnectEventsEmitter.onStreamEvent} */
|
69
|
+
onCommitEvent(eventName, message) {
|
70
|
+
var _a;
|
71
|
+
(_a = this.commitListeners) === null || _a === void 0 ? void 0 : _a.publish(new CustomEvent(CommitEventType, {
|
72
|
+
detail: {
|
73
|
+
eventName,
|
74
|
+
message,
|
75
|
+
},
|
76
|
+
}));
|
77
|
+
}
|
78
|
+
/** {@inheritDoc ConnectEvents.addMetadataListener} */
|
79
|
+
addMetadataListener(listener) {
|
80
|
+
var _a;
|
81
|
+
return (_a = this.metadataListeners) === null || _a === void 0 ? void 0 : _a.subscribe(listener);
|
82
|
+
}
|
83
|
+
/** {@inheritDoc ConnectEventsEmitter.onMetadataEvent} */
|
84
|
+
onMetadataEvent(resourceName, message, error) {
|
85
|
+
var _a;
|
86
|
+
(_a = this.metadataListeners) === null || _a === void 0 ? void 0 : _a.publish(new CustomEvent(MetadataEventType, {
|
87
|
+
detail: {
|
88
|
+
resourceName,
|
89
|
+
message,
|
90
|
+
error,
|
91
|
+
},
|
92
|
+
}));
|
93
|
+
}
|
94
|
+
}
|
95
|
+
/**
|
96
|
+
* ConnectEvents DI key.
|
97
|
+
*
|
98
|
+
* @privateRemarks
|
99
|
+
* Marked as internal to stop api-extractor becoming confused cross-linking tokens with the same name.
|
100
|
+
*
|
101
|
+
* @internal
|
102
|
+
*/
|
103
|
+
export const ConnectEvents = DI.createInterface((x) => x.singleton(DefaultConnectEvents));
|
104
|
+
/**
|
105
|
+
* ConnectEventsEmitter DI key.
|
106
|
+
*
|
107
|
+
* @privateRemarks
|
108
|
+
* ConnectEventsEmitter is used by Connect.
|
109
|
+
* Marked as internal to stop api-extractor becoming confused cross-linking tokens with the same name.
|
110
|
+
*
|
111
|
+
* @internal
|
112
|
+
*/
|
113
|
+
export const ConnectEventsEmitter = DI.createInterface((x) => x.aliasTo(ConnectEvents));
|
@@ -4,6 +4,7 @@ import { observable, volatile } from '@microsoft/fast-element';
|
|
4
4
|
import { DI, optional } from '@microsoft/fast-foundation';
|
5
5
|
import { MetaCache } from '../metadata';
|
6
6
|
import { isWebSocketExpression, logger } from '../utils';
|
7
|
+
import { ConnectEventsEmitter } from './connect.events';
|
7
8
|
import { ConnectConfig } from './connect.types';
|
8
9
|
import { HttpConnect } from './http.connect';
|
9
10
|
import { EventMessageType, MessageBuilder } from './message';
|
@@ -41,10 +42,11 @@ let DefaultConnect = class DefaultConnect {
|
|
41
42
|
var _a;
|
42
43
|
return (_a = this.socket.isConnectedSubject) === null || _a === void 0 ? void 0 : _a.asObservable();
|
43
44
|
}
|
44
|
-
constructor(socket, messageBuilder, metaCache, config = defaultConnectConfig) {
|
45
|
+
constructor(socket, messageBuilder, metaCache, events, config = defaultConnectConfig) {
|
45
46
|
this.socket = socket;
|
46
47
|
this.messageBuilder = messageBuilder;
|
47
48
|
this.metaCache = metaCache;
|
49
|
+
this.events = events;
|
48
50
|
this.config = config;
|
49
51
|
this.isWorking = false;
|
50
52
|
}
|
@@ -79,9 +81,16 @@ let DefaultConnect = class DefaultConnect {
|
|
79
81
|
});
|
80
82
|
}
|
81
83
|
stream(resourceName, onMessage, onError, params) {
|
82
|
-
const
|
83
|
-
logger.debug(`${
|
84
|
-
|
84
|
+
const msg = this.messageBuilder.createDataLogonMessage(resourceName, params);
|
85
|
+
logger.debug(`${msg.MESSAGE_TYPE} (stream) message created -> `, msg);
|
86
|
+
const resource = this.socket.sendForStream(msg, onMessage, onError, () => {
|
87
|
+
this.events.onStreamCompleteEvent(resource);
|
88
|
+
});
|
89
|
+
this.events.onStreamEvent(resourceName, msg, resource, {
|
90
|
+
onMessage,
|
91
|
+
onError,
|
92
|
+
});
|
93
|
+
return resource;
|
85
94
|
}
|
86
95
|
getMoreRows(sourceRef) {
|
87
96
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -90,6 +99,12 @@ let DefaultConnect = class DefaultConnect {
|
|
90
99
|
return this.socket.send(moreRowsMessage, false);
|
91
100
|
});
|
92
101
|
}
|
102
|
+
getMoreColumns(sourceRef) {
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
104
|
+
const message = this.messageBuilder.createMoreColumnsMessage(sourceRef);
|
105
|
+
return this.socket.send(message);
|
106
|
+
});
|
107
|
+
}
|
93
108
|
dataLogoff(streamSourceRef) {
|
94
109
|
return __awaiter(this, void 0, void 0, function* () {
|
95
110
|
const dataLogoffMessage = this.messageBuilder.createDataLogoffMessage(streamSourceRef);
|
@@ -109,6 +124,7 @@ let DefaultConnect = class DefaultConnect {
|
|
109
124
|
const metaRequestMessage = this.messageBuilder.createMetaRequestMessage(resourceName);
|
110
125
|
logger.debug(`${metaRequestMessage.MESSAGE_TYPE} (metadata) message created -> `, metaRequestMessage);
|
111
126
|
let details;
|
127
|
+
let error;
|
112
128
|
try {
|
113
129
|
this.isWorking = true;
|
114
130
|
const metaResponse = yield this.socket.send(metaRequestMessage);
|
@@ -118,9 +134,12 @@ let DefaultConnect = class DefaultConnect {
|
|
118
134
|
}
|
119
135
|
}
|
120
136
|
catch (e) {
|
137
|
+
error = e;
|
121
138
|
logger.error(e);
|
139
|
+
throw error;
|
122
140
|
}
|
123
141
|
finally {
|
142
|
+
this.events.onMetadataEvent(resourceName, metaRequestMessage, error);
|
124
143
|
this.isWorking = false;
|
125
144
|
}
|
126
145
|
return details;
|
@@ -166,9 +185,11 @@ let DefaultConnect = class DefaultConnect {
|
|
166
185
|
}
|
167
186
|
commitEvent(eventName, params) {
|
168
187
|
return __awaiter(this, void 0, void 0, function* () {
|
169
|
-
const
|
170
|
-
logger.debug(`${
|
171
|
-
|
188
|
+
const msg = this.messageBuilder.createCommitMessage(eventName, params);
|
189
|
+
logger.debug(`${msg.MESSAGE_TYPE} (commit) message created -> `, msg);
|
190
|
+
const promise = this.socket.send(msg);
|
191
|
+
this.events.onCommitEvent(eventName, msg);
|
192
|
+
return promise;
|
172
193
|
});
|
173
194
|
}
|
174
195
|
};
|
@@ -182,7 +203,8 @@ DefaultConnect = __decorate([
|
|
182
203
|
__param(0, Socket),
|
183
204
|
__param(1, MessageBuilder),
|
184
205
|
__param(2, MetaCache),
|
185
|
-
__param(3,
|
206
|
+
__param(3, ConnectEventsEmitter),
|
207
|
+
__param(4, optional(ConnectConfig))
|
186
208
|
], DefaultConnect);
|
187
209
|
export { DefaultConnect };
|
188
210
|
const useHttpConnect = FORCE_HTTP === 'true' || false;
|
@@ -162,6 +162,12 @@ let DefaultHttpConnect = class DefaultHttpConnect {
|
|
162
162
|
return this.send(moreRowsMessage);
|
163
163
|
});
|
164
164
|
}
|
165
|
+
getMoreColumns(sourceRef) {
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
167
|
+
const message = this.messageBuilder.createMoreColumnsMessage(sourceRef);
|
168
|
+
return this.send(message);
|
169
|
+
});
|
170
|
+
}
|
165
171
|
dataLogoff(streamSourceRef) {
|
166
172
|
return __awaiter(this, void 0, void 0, function* () {
|
167
173
|
const dataLogoffMessage = this.messageBuilder.createDataLogoffMessage(streamSourceRef);
|
@@ -1,8 +1,10 @@
|
|
1
|
+
export * from './connect.events';
|
1
2
|
export * from './connect';
|
2
3
|
export * from './connect.types';
|
3
4
|
export * from './http.connect';
|
4
5
|
export * from './http';
|
5
6
|
export * from './message';
|
6
7
|
export * from './serializers';
|
8
|
+
export * from './socket.status';
|
7
9
|
export * from './socket';
|
8
10
|
export * from './reconnectStrategy';
|
@@ -16,6 +16,8 @@ export var MessageType;
|
|
16
16
|
MessageType["HEARTBEAT_PING"] = "HEARTBEAT_PING";
|
17
17
|
MessageType["HEARTBEAT_PONG"] = "HEARTBEAT_PONG";
|
18
18
|
MessageType["MORE_ROWS"] = "MORE_ROWS";
|
19
|
+
MessageType["MORE_COLUMNS"] = "MORE_COLUMNS";
|
20
|
+
MessageType["MORE_COLUMNS_ACK"] = "MORE_COLUMNS_ACK";
|
19
21
|
MessageType["MSG_ACK"] = "MSG_ACK";
|
20
22
|
MessageType["MSG_NACK"] = "MSG_NACK";
|
21
23
|
MessageType["LOGOUT_ACK"] = "LOGOUT_ACK";
|
@@ -62,10 +64,25 @@ export const messageOrThrow = (message) => {
|
|
62
64
|
}
|
63
65
|
return message;
|
64
66
|
};
|
67
|
+
/**
|
68
|
+
* Check if the message contains an error code.
|
69
|
+
* @param message - The message object.
|
70
|
+
* @param code - The error code.
|
71
|
+
* @public
|
72
|
+
*/
|
73
|
+
export const messageHasErrorCode = (message, code) => {
|
74
|
+
return Array.isArray(message === null || message === void 0 ? void 0 : message.ERROR)
|
75
|
+
? message === null || message === void 0 ? void 0 : message.ERROR.some((error) => error.CODE === code)
|
76
|
+
: false;
|
77
|
+
};
|
65
78
|
/**
|
66
79
|
* TODO: Abstract out localStorage interaction with shell io stuff
|
67
80
|
*/
|
68
|
-
|
81
|
+
/**
|
82
|
+
* Default MessageBuilder implementation.
|
83
|
+
* @public
|
84
|
+
*/
|
85
|
+
let DefaultMessageBuilder = class DefaultMessageBuilder {
|
69
86
|
/**
|
70
87
|
* UUID will be created in the DI with the App specific requirements.
|
71
88
|
* Keeping it encapsulated means messages will always conform.
|
@@ -207,6 +224,9 @@ let MessageBuilderService = class MessageBuilderService {
|
|
207
224
|
SESSION_AUTH_TOKEN: this.session.getSessionStorageItem('authToken'),
|
208
225
|
};
|
209
226
|
}
|
227
|
+
createMoreColumnsMessage(sourceRef) {
|
228
|
+
return Object.assign(Object.assign({}, this.createMoreRowsMessage(sourceRef)), { MESSAGE_TYPE: MessageType.MORE_COLUMNS });
|
229
|
+
}
|
210
230
|
createHTTPHeadersFromMessage(message, contentType = 'application/json; charset=UTF-8') {
|
211
231
|
const headers = { 'Content-type': contentType };
|
212
232
|
if (message.SOURCE_REF) {
|
@@ -222,12 +242,13 @@ let MessageBuilderService = class MessageBuilderService {
|
|
222
242
|
return headers;
|
223
243
|
}
|
224
244
|
};
|
225
|
-
|
245
|
+
DefaultMessageBuilder = __decorate([
|
226
246
|
__param(0, Session),
|
227
247
|
__param(1, UUID)
|
228
|
-
],
|
248
|
+
], DefaultMessageBuilder);
|
249
|
+
export { DefaultMessageBuilder };
|
229
250
|
/**
|
230
251
|
* The DI token for the MessageBUilder interface.
|
231
252
|
* @internal
|
232
253
|
*/
|
233
|
-
export const MessageBuilder = DI.createInterface((x) => x.singleton(
|
254
|
+
export const MessageBuilder = DI.createInterface((x) => x.singleton(DefaultMessageBuilder));
|
@@ -3,13 +3,14 @@ import { UUID } from '@genesislcap/foundation-utils';
|
|
3
3
|
import { JSONSerializer } from '@genesislcap/foundation-utils';
|
4
4
|
import { observable } from '@microsoft/fast-element';
|
5
5
|
import { DI } from '@microsoft/fast-foundation';
|
6
|
-
import {
|
6
|
+
import { Observable, of, Subject, Subscription, takeUntil, throwError } from 'rxjs';
|
7
7
|
import { filter, mergeMap, switchMap, takeWhile } from 'rxjs/operators';
|
8
8
|
import { WebSocketSubject } from 'rxjs/webSocket';
|
9
9
|
import { Session } from '../session';
|
10
10
|
import { logger } from '../utils';
|
11
11
|
import { EventMessageType, MessageBuilder, MessageType } from './message';
|
12
12
|
import { exponentialScheduler, linearScheduler, MAX_RECONNECT_ATTEMPTS, retryInterval, SocketReconnectStrategy, } from './reconnectStrategy';
|
13
|
+
import { SocketStatus } from './socket.status';
|
13
14
|
import { Ticker } from './ticker';
|
14
15
|
/**
|
15
16
|
* Subject that wraps a WebSocketSubject and provides a Subject interface for sending and receiving messages.
|
@@ -76,23 +77,48 @@ export class SocketMessageHandler {
|
|
76
77
|
return this._isSubscription;
|
77
78
|
}
|
78
79
|
}
|
79
|
-
|
80
|
-
|
81
|
-
|
80
|
+
/**
|
81
|
+
* Default Socket implementation.
|
82
|
+
* @public
|
83
|
+
*/
|
84
|
+
let DefaultSocket = class DefaultSocket {
|
85
|
+
get isConfigured() {
|
86
|
+
return this.status.isConfigured;
|
87
|
+
}
|
88
|
+
get isConnecting() {
|
89
|
+
return this.status.isConnecting;
|
90
|
+
}
|
91
|
+
get isConnected() {
|
92
|
+
return this.status.isConnected;
|
93
|
+
}
|
94
|
+
get isConnectedSubject() {
|
95
|
+
return this.status.isConnectedSubject;
|
96
|
+
}
|
97
|
+
get isDisconnected() {
|
98
|
+
return this.status.isDisconnected;
|
99
|
+
}
|
100
|
+
get isDisconnectedByServer() {
|
101
|
+
return this.status.isDisconnectedByServer;
|
102
|
+
}
|
103
|
+
get isReconnecting() {
|
104
|
+
return this.status.isReconnecting;
|
82
105
|
}
|
83
|
-
|
106
|
+
get hasValidSession() {
|
107
|
+
return this.status.hasValidSession;
|
108
|
+
}
|
109
|
+
set hasValidSession(value) {
|
110
|
+
this.status.hasValidSession = value;
|
111
|
+
}
|
112
|
+
constructor(messageBuilder, session, serializer, uuid, status) {
|
84
113
|
this.messageBuilder = messageBuilder;
|
85
114
|
this.session = session;
|
86
115
|
this.serializer = serializer;
|
87
116
|
this.uuid = uuid;
|
117
|
+
this.status = status;
|
88
118
|
this.defaultInterval = 10000;
|
89
119
|
this.secondsMultiplier = 1000;
|
90
|
-
this.isConnectedSubject = new BehaviorSubject(false);
|
91
|
-
this.isConnected = false;
|
92
|
-
this.hasValidSession = false;
|
93
120
|
this.heartbeatIsEnabled = true;
|
94
121
|
this.heartbeatInterval = this.defaultInterval;
|
95
|
-
this.isReconnecting = false;
|
96
122
|
this.socketMessages = () => this.wsMessages;
|
97
123
|
}
|
98
124
|
get heartbeatLoggingIsEnabled() {
|
@@ -110,6 +136,7 @@ let SocketService = class SocketService {
|
|
110
136
|
return new Promise((resolve) => {
|
111
137
|
var _a, _b, _c, _d;
|
112
138
|
logger.info(`${this.isReconnecting ? 'Reconnecting' : 'Connecting'} to ${this.url}`);
|
139
|
+
this.status.isConnecting = !this.isReconnecting;
|
113
140
|
const cleanMessages = !this.isReconnecting || !((_a = this.reconnectOptions) === null || _a === void 0 ? void 0 : _a.reconnectStreams);
|
114
141
|
if (cleanMessages) {
|
115
142
|
this.cleanMessages();
|
@@ -120,7 +147,7 @@ let SocketService = class SocketService {
|
|
120
147
|
openObserver: {
|
121
148
|
next: () => {
|
122
149
|
this.session.setSessionStorageItem('hostUrl', this.url);
|
123
|
-
this.isConnected = true;
|
150
|
+
this.status.isConnected = true;
|
124
151
|
this.prepareHeartbeat();
|
125
152
|
logger.info(`WebSocket connection is now open`);
|
126
153
|
resolve(this.isConnected);
|
@@ -128,9 +155,8 @@ let SocketService = class SocketService {
|
|
128
155
|
},
|
129
156
|
closeObserver: {
|
130
157
|
next: (closeEvent) => {
|
131
|
-
this.
|
132
|
-
this.
|
133
|
-
if (this.disconnectedByServer) {
|
158
|
+
this.status.onClose(closeEvent);
|
159
|
+
if (this.isDisconnectedByServer) {
|
134
160
|
logger.info(`WebSocket connection was closed due an error - Code: ${closeEvent.code} ${closeEvent.reason ? ' | Reason: ' + closeEvent.reason : ''}`);
|
135
161
|
}
|
136
162
|
resolve(this.isConnected);
|
@@ -196,8 +222,7 @@ let SocketService = class SocketService {
|
|
196
222
|
}
|
197
223
|
case MessageType.QUERY_UPDATE: {
|
198
224
|
if (!messageHandler.isSubscription) {
|
199
|
-
|
200
|
-
this.send(dataLogoffMessage);
|
225
|
+
this.sendDataLogoff(SOURCE_REF);
|
201
226
|
}
|
202
227
|
break;
|
203
228
|
}
|
@@ -227,7 +252,7 @@ let SocketService = class SocketService {
|
|
227
252
|
};
|
228
253
|
const onComplete = () => {
|
229
254
|
var _a;
|
230
|
-
if (this.
|
255
|
+
if (this.isDisconnectedByServer && ((_a = this.connectOptions) === null || _a === void 0 ? void 0 : _a.alwaysOn)) {
|
231
256
|
this.reconnect();
|
232
257
|
return;
|
233
258
|
}
|
@@ -238,6 +263,7 @@ let SocketService = class SocketService {
|
|
238
263
|
error: onError,
|
239
264
|
complete: onComplete,
|
240
265
|
});
|
266
|
+
this.status.isConfigured = true;
|
241
267
|
});
|
242
268
|
}
|
243
269
|
prepareHeartbeat() {
|
@@ -275,7 +301,7 @@ let SocketService = class SocketService {
|
|
275
301
|
if (this.isReconnecting || notAlwaysOnAndHeartbeating) {
|
276
302
|
return;
|
277
303
|
}
|
278
|
-
this.isReconnecting = true;
|
304
|
+
this.status.isReconnecting = true;
|
279
305
|
const scheduler = ((_c = this.reconnectOptions) === null || _c === void 0 ? void 0 : _c.reconnectStrategy) === SocketReconnectStrategy.Exponential
|
280
306
|
? exponentialScheduler
|
281
307
|
: linearScheduler;
|
@@ -293,6 +319,7 @@ let SocketService = class SocketService {
|
|
293
319
|
if (value < attemptsAmount) {
|
294
320
|
return of(value);
|
295
321
|
}
|
322
|
+
this.status.reconnectionLimitReached = true;
|
296
323
|
return throwError(() => new Error(`Max reconnect attempts ${attemptsAmount} reached.`));
|
297
324
|
}))
|
298
325
|
: of(-1)), takeWhile(() => this.websocket && !this.isConnected));
|
@@ -306,11 +333,11 @@ let SocketService = class SocketService {
|
|
306
333
|
var _a;
|
307
334
|
logger.debug(error);
|
308
335
|
(_a = this.socketSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
309
|
-
this.isReconnecting = false;
|
336
|
+
this.status.isReconnecting = false;
|
310
337
|
},
|
311
338
|
complete: () => {
|
312
339
|
logger.info(this.isConnected ? 'Reconnected' : 'Disconnected');
|
313
|
-
this.isReconnecting = false;
|
340
|
+
this.status.isReconnecting = false;
|
314
341
|
this.wsMessageHandlers.forEach((mh) => {
|
315
342
|
if (mh.isSubscription) {
|
316
343
|
this.websocket.next(mh.sentMessage);
|
@@ -320,7 +347,8 @@ let SocketService = class SocketService {
|
|
320
347
|
});
|
321
348
|
}
|
322
349
|
reset() {
|
323
|
-
this.isConnected = false;
|
350
|
+
this.status.isConnected = false;
|
351
|
+
this.status.isConfigured = false;
|
324
352
|
this.websocket && this.websocket.complete();
|
325
353
|
this.websocket = null;
|
326
354
|
this.cleanMessages();
|
@@ -332,8 +360,7 @@ let SocketService = class SocketService {
|
|
332
360
|
}
|
333
361
|
send(message, needsHandling = true) {
|
334
362
|
if (!this.isConnected) {
|
335
|
-
Promise.reject(new Error('WebSocket connection is closed'));
|
336
|
-
return;
|
363
|
+
return Promise.reject(new Error('WebSocket connection is closed'));
|
337
364
|
}
|
338
365
|
const sendingMessasgeLog = `Sending Message for SourceRef: ${message.SOURCE_REF} | MessageType: ${message.MESSAGE_TYPE}`;
|
339
366
|
this.logMessageTypeFlow(message.MESSAGE_TYPE, logger.info, sendingMessasgeLog);
|
@@ -350,7 +377,7 @@ let SocketService = class SocketService {
|
|
350
377
|
this.websocket.next(message);
|
351
378
|
});
|
352
379
|
}
|
353
|
-
sendForStream(message, onMessage, onError) {
|
380
|
+
sendForStream(message, onMessage, onError, onComplete) {
|
354
381
|
if (!this.isConnected) {
|
355
382
|
return throwError(() => new Error('WebSocket connection is closed'));
|
356
383
|
}
|
@@ -361,13 +388,44 @@ let SocketService = class SocketService {
|
|
361
388
|
this.logMessageTypeFlow(message.MESSAGE_TYPE, logger.info, sendingMessageLog);
|
362
389
|
this.setMessageHandler(message, onMessage, onError, true);
|
363
390
|
this.websocket.next(message);
|
364
|
-
|
391
|
+
/**
|
392
|
+
* @privateRemarks
|
393
|
+
* Running the data logoff from here makes more sense given the network monitor actor is optionally added.
|
394
|
+
*/
|
395
|
+
return new Observable((subscriber) => {
|
396
|
+
const destroyNotifier = new Subject();
|
397
|
+
this.wsMessages
|
398
|
+
.pipe(filter((msg) => msg.SOURCE_REF === message.SOURCE_REF), takeUntil(destroyNotifier))
|
399
|
+
.subscribe({
|
400
|
+
next: (value) => {
|
401
|
+
subscriber.next(value);
|
402
|
+
},
|
403
|
+
error: (err) => {
|
404
|
+
subscriber.error(err);
|
405
|
+
},
|
406
|
+
complete: () => {
|
407
|
+
subscriber.complete();
|
408
|
+
},
|
409
|
+
});
|
410
|
+
return () => {
|
411
|
+
destroyNotifier.complete();
|
412
|
+
this.sendDataLogoff(message.SOURCE_REF);
|
413
|
+
this.removeMessageHandler(message.SOURCE_REF);
|
414
|
+
onComplete && onComplete();
|
415
|
+
};
|
416
|
+
});
|
365
417
|
}
|
366
418
|
setMessageHandler(message, onMessage, onError, isSubscription = false) {
|
367
419
|
const settingMessageHandlerLog = `Setting Message Handler for SourceRef: ${message.SOURCE_REF} | MessageType: ${message.MESSAGE_TYPE}`;
|
368
420
|
this.logMessageTypeFlow(message.MESSAGE_TYPE, logger.debug, settingMessageHandlerLog);
|
369
421
|
this.wsMessageHandlers.set(message.SOURCE_REF, new SocketMessageHandler(message, onMessage, onError, isSubscription));
|
370
422
|
}
|
423
|
+
sendDataLogoff(sourceRef) {
|
424
|
+
if (!this.hasValidSession) {
|
425
|
+
return;
|
426
|
+
}
|
427
|
+
this.send(this.messageBuilder.createDataLogoffMessage(sourceRef), false);
|
428
|
+
}
|
371
429
|
removeMessageHandler(sourceRef) {
|
372
430
|
this.wsMessageHandlers.delete(sourceRef);
|
373
431
|
}
|
@@ -378,6 +436,9 @@ let SocketService = class SocketService {
|
|
378
436
|
}
|
379
437
|
logMessageTypeFlow(messageType, logFunc, logMsg) {
|
380
438
|
switch (messageType) {
|
439
|
+
case EventMessageType.DATA_LOGOFF:
|
440
|
+
logFunc(logMsg);
|
441
|
+
break;
|
381
442
|
case MessageType.HEARTBEAT_PING:
|
382
443
|
case MessageType.HEARTBEAT_PONG:
|
383
444
|
if (this.heartbeatLoggingIsEnabled) {
|
@@ -394,36 +455,44 @@ let SocketService = class SocketService {
|
|
394
455
|
};
|
395
456
|
__decorate([
|
396
457
|
observable
|
397
|
-
],
|
398
|
-
__decorate([
|
399
|
-
observable
|
400
|
-
], SocketService.prototype, "wsMessages", void 0);
|
401
|
-
__decorate([
|
402
|
-
observable
|
403
|
-
], SocketService.prototype, "wsMessageHandlers", void 0);
|
458
|
+
], DefaultSocket.prototype, "websocket", void 0);
|
404
459
|
__decorate([
|
405
460
|
observable
|
406
|
-
],
|
461
|
+
], DefaultSocket.prototype, "wsMessages", void 0);
|
407
462
|
__decorate([
|
408
463
|
observable
|
409
|
-
],
|
464
|
+
], DefaultSocket.prototype, "wsMessageHandlers", void 0);
|
410
465
|
__decorate([
|
411
466
|
observable
|
412
|
-
],
|
413
|
-
__decorate([
|
414
|
-
observable
|
415
|
-
], SocketService.prototype, "heartbeatIsEnabled", void 0);
|
416
|
-
__decorate([
|
417
|
-
observable
|
418
|
-
], SocketService.prototype, "isReconnecting", void 0);
|
419
|
-
SocketService = __decorate([
|
467
|
+
], DefaultSocket.prototype, "heartbeatIsEnabled", void 0);
|
468
|
+
DefaultSocket = __decorate([
|
420
469
|
__param(0, MessageBuilder),
|
421
470
|
__param(1, Session),
|
422
471
|
__param(2, JSONSerializer),
|
423
|
-
__param(3, UUID)
|
424
|
-
|
472
|
+
__param(3, UUID),
|
473
|
+
__param(4, SocketStatus)
|
474
|
+
], DefaultSocket);
|
475
|
+
export { DefaultSocket };
|
425
476
|
/**
|
426
477
|
* The DI token for the Socket interface.
|
427
478
|
* @internal
|
428
479
|
*/
|
429
|
-
export const Socket = DI.createInterface((x) => x.singleton(
|
480
|
+
export const Socket = DI.createInterface((x) => x.singleton(DefaultSocket));
|
481
|
+
/**
|
482
|
+
* Gets Socket from the DI container.
|
483
|
+
*
|
484
|
+
* @remarks
|
485
|
+
* A utility method for host applications that are not using decorators or the DI container.
|
486
|
+
*
|
487
|
+
* @example
|
488
|
+
* ```ts
|
489
|
+
* import { getSocket } from '@genesislcap/foundation-comms';
|
490
|
+
* ...
|
491
|
+
* private socket = getSocket();
|
492
|
+
* ```
|
493
|
+
*
|
494
|
+
* @public
|
495
|
+
*/
|
496
|
+
export function getSocket() {
|
497
|
+
return DI.getOrCreateDOMContainer().get(Socket);
|
498
|
+
}
|