@voicenter-team/events-sdk 0.0.3 → 0.0.5
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/.idea/inspectionProfiles/Project_Default.xml +5 -5
- package/dist/voicenter-events-sdk.cjs.js +6 -6
- package/dist/voicenter-events-sdk.cjs.js.map +1 -1
- package/dist/voicenter-events-sdk.d.ts +4 -0
- package/dist/voicenter-events-sdk.es.js +70 -59
- package/dist/voicenter-events-sdk.es.js.map +1 -1
- package/dist/voicenter-events-sdk.iife.js +6 -6
- package/dist/voicenter-events-sdk.iife.js.map +1 -1
- package/dist/voicenter-events-sdk.umd.js +6 -6
- package/dist/voicenter-events-sdk.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/events-sdk/events-sdk.class.ts +12 -0
- package/src/classes/socket-io/socket-io.class.ts +11 -2
- package/interface.ts +0 -261
package/package.json
CHANGED
|
@@ -127,17 +127,29 @@ class EventsSdkClass{
|
|
|
127
127
|
this.server = this.findCurrentServer()
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
this.socketIoClass.doReconnect = true
|
|
131
|
+
|
|
130
132
|
this.socketIoClass.initSocketConnection()
|
|
131
133
|
|
|
132
134
|
this.socketIoClass.initSocketEvents()
|
|
133
135
|
|
|
134
136
|
this.socketIoClass.initKeepAlive()
|
|
135
137
|
|
|
138
|
+
// TODO: check if it is needed here
|
|
136
139
|
if (skipLogin) {
|
|
137
140
|
return
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
143
|
|
|
144
|
+
public disconnect () {
|
|
145
|
+
this.socketIoClass.doReconnect = false
|
|
146
|
+
this.socketIoClass.closeAllConnections()
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public clearKeepAliveInterval () {
|
|
150
|
+
this.socketIoClass.clearKeepAliveInterval()
|
|
151
|
+
}
|
|
152
|
+
|
|
141
153
|
private findCurrentServer (): Server {
|
|
142
154
|
if (this.servers.length) {
|
|
143
155
|
this.server = this.servers[0]
|
|
@@ -14,6 +14,7 @@ export class SocketIoClass{
|
|
|
14
14
|
public io: SocketTyped | undefined
|
|
15
15
|
public ioFunction: TypedSocketIo | undefined
|
|
16
16
|
public lastEventTimestamp = new Date().getTime()
|
|
17
|
+
public doReconnect = true
|
|
17
18
|
private keepAliveInterval: ReturnType<typeof setInterval> | undefined
|
|
18
19
|
private keepReconnectInterval: ReturnType<typeof setInterval> | undefined
|
|
19
20
|
private connected = false
|
|
@@ -82,10 +83,14 @@ export class SocketIoClass{
|
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
public
|
|
86
|
+
public clearKeepAliveInterval () {
|
|
86
87
|
if (this.keepAliveInterval) {
|
|
87
88
|
clearInterval(this.keepAliveInterval)
|
|
88
89
|
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public initKeepAlive () {
|
|
93
|
+
this.clearKeepAliveInterval()
|
|
89
94
|
|
|
90
95
|
this.keepAliveInterval = setInterval(async () => {
|
|
91
96
|
const now = new Date().getTime()
|
|
@@ -115,7 +120,7 @@ export class SocketIoClass{
|
|
|
115
120
|
if (this.io) {
|
|
116
121
|
this.io.close()
|
|
117
122
|
|
|
118
|
-
this.io
|
|
123
|
+
this.io?.disconnect()
|
|
119
124
|
|
|
120
125
|
this.io = undefined
|
|
121
126
|
}
|
|
@@ -159,6 +164,10 @@ export class SocketIoClass{
|
|
|
159
164
|
|
|
160
165
|
this.eventsSdkClass.emit(EventsEnum.ONLINE_STATUS_EVENT, { isSocketConnected: false })
|
|
161
166
|
|
|
167
|
+
if (!this.doReconnect) {
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
|
|
162
171
|
this.keepReconnectInterval = setInterval(() => {
|
|
163
172
|
console.log('attempt to connect...')
|
|
164
173
|
this.eventsSdkClass.connect(ServerParameter.NEXT, true)
|
package/interface.ts
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
interface options {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* the authentication payload sent when connecting to the Namespace
|
|
5
|
-
*/
|
|
6
|
-
auth?: {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
} | ((cb: (data: object) => void) => void);
|
|
9
|
-
/**
|
|
10
|
-
* The maximum number of retries. Above the limit, the packet will be discarded.
|
|
11
|
-
*
|
|
12
|
-
* Using `Infinity` means the delivery guarantee is "at-least-once" (instead of "at-most-once" by default), but a
|
|
13
|
-
* smaller value like 10 should be sufficient in practice.
|
|
14
|
-
*/
|
|
15
|
-
retries?: number;
|
|
16
|
-
/**
|
|
17
|
-
* The default timeout in milliseconds used when waiting for an acknowledgement.
|
|
18
|
-
*/
|
|
19
|
-
ackTimeout?: number;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The host that we're connecting to. Set from the URI passed when connecting
|
|
23
|
-
*/
|
|
24
|
-
host: string;
|
|
25
|
-
/**
|
|
26
|
-
* The hostname for our connection. Set from the URI passed when connecting
|
|
27
|
-
*/
|
|
28
|
-
hostname: string;
|
|
29
|
-
/**
|
|
30
|
-
* If this is a secure connection. Set from the URI passed when connecting
|
|
31
|
-
*/
|
|
32
|
-
secure: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* The port for our connection. Set from the URI passed when connecting
|
|
35
|
-
*/
|
|
36
|
-
port: string | number;
|
|
37
|
-
/**
|
|
38
|
-
* Any query parameters in our uri. Set from the URI passed when connecting
|
|
39
|
-
*/
|
|
40
|
-
query: {
|
|
41
|
-
[key: string]: any;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* `http.Agent` to use, defaults to `false` (NodeJS only)
|
|
45
|
-
*
|
|
46
|
-
* Note: the type should be "undefined | http.Agent | https.Agent | false", but this would break browser-only clients.
|
|
47
|
-
*
|
|
48
|
-
* @see https://nodejs.org/api/http.html#httprequestoptions-callback
|
|
49
|
-
*/
|
|
50
|
-
agent: string | boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Whether the client should try to upgrade the transport from
|
|
53
|
-
* long-polling to something better.
|
|
54
|
-
* @default true
|
|
55
|
-
*/
|
|
56
|
-
upgrade: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Forces base 64 encoding for polling transport even when XHR2
|
|
59
|
-
* responseType is available and WebSocket even if the used standard
|
|
60
|
-
* supports binary.
|
|
61
|
-
*/
|
|
62
|
-
forceBase64: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* The param name to use as our timestamp key
|
|
65
|
-
* @default 't'
|
|
66
|
-
*/
|
|
67
|
-
timestampParam: string;
|
|
68
|
-
/**
|
|
69
|
-
* Whether to add the timestamp with each transport request. Note: this
|
|
70
|
-
* is ignored if the browser is IE or Android, in which case requests
|
|
71
|
-
* are always stamped
|
|
72
|
-
* @default false
|
|
73
|
-
*/
|
|
74
|
-
timestampRequests: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* A list of transports to try (in order). Engine.io always attempts to
|
|
77
|
-
* connect directly with the first one, provided the feature detection test
|
|
78
|
-
* for it passes.
|
|
79
|
-
*
|
|
80
|
-
* @default ['polling','websocket', 'webtransport']
|
|
81
|
-
*/
|
|
82
|
-
transports: string[];
|
|
83
|
-
/**
|
|
84
|
-
* If true and if the previous websocket connection to the server succeeded,
|
|
85
|
-
* the connection attempt will bypass the normal upgrade process and will
|
|
86
|
-
* initially try websocket. A connection attempt following a transport error
|
|
87
|
-
* will use the normal upgrade process. It is recommended you turn this on
|
|
88
|
-
* only when using SSL/TLS connections, or if you know that your network does
|
|
89
|
-
* not block websockets.
|
|
90
|
-
* @default false
|
|
91
|
-
*/
|
|
92
|
-
rememberUpgrade: boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Are we only interested in transports that support binary?
|
|
95
|
-
*/
|
|
96
|
-
onlyBinaryUpgrades: boolean;
|
|
97
|
-
/**
|
|
98
|
-
* Timeout for xhr-polling requests in milliseconds (0) (only for polling transport)
|
|
99
|
-
*/
|
|
100
|
-
requestTimeout: number;
|
|
101
|
-
/**
|
|
102
|
-
* Transport options for Node.js client (headers etc)
|
|
103
|
-
*/
|
|
104
|
-
transportOptions: Object;
|
|
105
|
-
/**
|
|
106
|
-
* (SSL) Certificate, Private key and CA certificates to use for SSL.
|
|
107
|
-
* Can be used in Node.js client environment to manually specify
|
|
108
|
-
* certificate information.
|
|
109
|
-
*/
|
|
110
|
-
pfx: string;
|
|
111
|
-
/**
|
|
112
|
-
* (SSL) Private key to use for SSL. Can be used in Node.js client
|
|
113
|
-
* environment to manually specify certificate information.
|
|
114
|
-
*/
|
|
115
|
-
key: string;
|
|
116
|
-
/**
|
|
117
|
-
* (SSL) A string or passphrase for the private key or pfx. Can be
|
|
118
|
-
* used in Node.js client environment to manually specify certificate
|
|
119
|
-
* information.
|
|
120
|
-
*/
|
|
121
|
-
passphrase: string;
|
|
122
|
-
/**
|
|
123
|
-
* (SSL) Public x509 certificate to use. Can be used in Node.js client
|
|
124
|
-
* environment to manually specify certificate information.
|
|
125
|
-
*/
|
|
126
|
-
cert: string;
|
|
127
|
-
/**
|
|
128
|
-
* (SSL) An authority certificate or array of authority certificates to
|
|
129
|
-
* check the remote host against.. Can be used in Node.js client
|
|
130
|
-
* environment to manually specify certificate information.
|
|
131
|
-
*/
|
|
132
|
-
ca: string | string[];
|
|
133
|
-
/**
|
|
134
|
-
* (SSL) A string describing the ciphers to use or exclude. Consult the
|
|
135
|
-
* [cipher format list]
|
|
136
|
-
* (http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT) for
|
|
137
|
-
* details on the format.. Can be used in Node.js client environment to
|
|
138
|
-
* manually specify certificate information.
|
|
139
|
-
*/
|
|
140
|
-
ciphers: string;
|
|
141
|
-
/**
|
|
142
|
-
* (SSL) If true, the server certificate is verified against the list of
|
|
143
|
-
* supplied CAs. An 'error' event is emitted if verification fails.
|
|
144
|
-
* Verification happens at the connection level, before the HTTP request
|
|
145
|
-
* is sent. Can be used in Node.js client environment to manually specify
|
|
146
|
-
* certificate information.
|
|
147
|
-
*/
|
|
148
|
-
rejectUnauthorized: boolean;
|
|
149
|
-
/**
|
|
150
|
-
* Headers that will be passed for each request to the server (via xhr-polling and via websockets).
|
|
151
|
-
* These values then can be used during handshake or for special proxies.
|
|
152
|
-
*/
|
|
153
|
-
extraHeaders?: {
|
|
154
|
-
[header: string]: string;
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* Whether to include credentials (cookies, authorization headers, TLS
|
|
158
|
-
* client certificates, etc.) with cross-origin XHR polling requests
|
|
159
|
-
* @default false
|
|
160
|
-
*/
|
|
161
|
-
withCredentials: boolean;
|
|
162
|
-
/**
|
|
163
|
-
* Whether to automatically close the connection whenever the beforeunload event is received.
|
|
164
|
-
* @default false
|
|
165
|
-
*/
|
|
166
|
-
closeOnBeforeunload: boolean;
|
|
167
|
-
/**
|
|
168
|
-
* Whether to always use the native timeouts. This allows the client to
|
|
169
|
-
* reconnect when the native timeout functions are overridden, such as when
|
|
170
|
-
* mock clocks are installed.
|
|
171
|
-
* @default false
|
|
172
|
-
*/
|
|
173
|
-
useNativeTimers: boolean;
|
|
174
|
-
/**
|
|
175
|
-
* weather we should unref the reconnect timer when it is
|
|
176
|
-
* create automatically
|
|
177
|
-
* @default false
|
|
178
|
-
*/
|
|
179
|
-
autoUnref: boolean;
|
|
180
|
-
/**
|
|
181
|
-
* parameters of the WebSocket permessage-deflate extension (see ws module api docs). Set to false to disable.
|
|
182
|
-
* @default false
|
|
183
|
-
*/
|
|
184
|
-
perMessageDeflate: {
|
|
185
|
-
threshold: number;
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* The path to get our client file from, in the case of the server
|
|
189
|
-
* serving it
|
|
190
|
-
* @default '/engine.io'
|
|
191
|
-
*/
|
|
192
|
-
path: string;
|
|
193
|
-
/**
|
|
194
|
-
* Whether we should add a trailing slash to the request path.
|
|
195
|
-
* @default true
|
|
196
|
-
*/
|
|
197
|
-
addTrailingSlash: boolean;
|
|
198
|
-
/**
|
|
199
|
-
* Either a single protocol string or an array of protocol strings. These strings are used to indicate sub-protocols,
|
|
200
|
-
* so that a single server can implement multiple WebSocket sub-protocols (for example, you might want one server to
|
|
201
|
-
* be able to handle different types of interactions depending on the specified protocol)
|
|
202
|
-
* @default []
|
|
203
|
-
*/
|
|
204
|
-
protocols: string | string[];
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Should we force a new Manager for this connection?
|
|
208
|
-
* @default false
|
|
209
|
-
*/
|
|
210
|
-
forceNew: boolean;
|
|
211
|
-
/**
|
|
212
|
-
* Should we multiplex our connection (reuse existing Manager) ?
|
|
213
|
-
* @default true
|
|
214
|
-
*/
|
|
215
|
-
multiplex: boolean;
|
|
216
|
-
/**
|
|
217
|
-
* The path to get our client file from, in the case of the server
|
|
218
|
-
* serving it
|
|
219
|
-
* @default '/socket.io'
|
|
220
|
-
*/
|
|
221
|
-
path: string;
|
|
222
|
-
/**
|
|
223
|
-
* Should we allow reconnections?
|
|
224
|
-
* @default true
|
|
225
|
-
*/
|
|
226
|
-
reconnection: boolean;
|
|
227
|
-
/**
|
|
228
|
-
* How many reconnection attempts should we try?
|
|
229
|
-
* @default Infinity
|
|
230
|
-
*/
|
|
231
|
-
reconnectionAttempts: number;
|
|
232
|
-
/**
|
|
233
|
-
* The time delay in milliseconds between reconnection attempts
|
|
234
|
-
* @default 1000
|
|
235
|
-
*/
|
|
236
|
-
reconnectionDelay: number;
|
|
237
|
-
/**
|
|
238
|
-
* The max time delay in milliseconds between reconnection attempts
|
|
239
|
-
* @default 5000
|
|
240
|
-
*/
|
|
241
|
-
reconnectionDelayMax: number;
|
|
242
|
-
/**
|
|
243
|
-
* Used in the exponential backoff jitter when reconnecting
|
|
244
|
-
* @default 0.5
|
|
245
|
-
*/
|
|
246
|
-
randomizationFactor: number;
|
|
247
|
-
/**
|
|
248
|
-
* The timeout in milliseconds for our connection attempt
|
|
249
|
-
* @default 20000
|
|
250
|
-
*/
|
|
251
|
-
timeout: number;
|
|
252
|
-
/**
|
|
253
|
-
* Should we automatically connect?
|
|
254
|
-
* @default true
|
|
255
|
-
*/
|
|
256
|
-
autoConnect: boolean;
|
|
257
|
-
/**
|
|
258
|
-
* the parser to use. Defaults to an instance of the Parser that ships with socket.io.
|
|
259
|
-
*/
|
|
260
|
-
parser: any;
|
|
261
|
-
}
|