@livequery/rest 2.0.27 → 2.0.28
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/build/RestTransporter.js +2 -2
- package/build/Socket.js +2 -2
- package/package.json +1 -1
package/build/RestTransporter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { of, firstValueFrom } from 'rxjs';
|
|
2
|
-
import { catchError, map, mergeMap } from 'rxjs/operators';
|
|
2
|
+
import { catchError, filter, map, mergeMap } from 'rxjs/operators';
|
|
3
3
|
import { merge, pipe } from 'rxjs';
|
|
4
4
|
import { Socket } from './Socket.js';
|
|
5
5
|
import qs from 'query-string';
|
|
@@ -86,7 +86,7 @@ export class RestTransporter {
|
|
|
86
86
|
...this.socket ? {
|
|
87
87
|
socket_id: this.socket.client_id,
|
|
88
88
|
'x-lcid': this.socket.client_id,
|
|
89
|
-
'x-lgid': await firstValueFrom(this.socket.$gateway.pipe(map(g => g.id)))
|
|
89
|
+
'x-lgid': await firstValueFrom(this.socket.$gateway.pipe(filter(Boolean), map(g => g.id)))
|
|
90
90
|
} : {}
|
|
91
91
|
};
|
|
92
92
|
try {
|
package/build/Socket.js
CHANGED
|
@@ -12,11 +12,11 @@ export class Socket {
|
|
|
12
12
|
#init() {
|
|
13
13
|
if (typeof WebSocket == 'undefined')
|
|
14
14
|
return;
|
|
15
|
-
return of(1).pipe(mergeMap(() => this.ws_url_fatory())
|
|
15
|
+
return of(1).pipe(mergeMap(async () => new WebSocket(await this.ws_url_fatory())), switchMap(ws => merge(fromEvent(ws, 'closed').pipe(map(e => { throw e; })), fromEvent(ws, 'close').pipe(map(e => { throw e; })), fromEvent(ws, 'error').pipe(map(e => { throw e; })), fromEvent(ws, 'open').pipe(switchMap(() => interval(60000)), tap(() => ws.send(JSON.stringify({ event: 'ping' })))), fromEvent(ws, 'open').pipe(tap(() => {
|
|
16
16
|
console.log(this.$reconnect.getValue() == 0 ? 'Websocket connected' : `Websocket re-connected (${this.$reconnect.getValue()})`);
|
|
17
17
|
this.$reconnect.next(this.$reconnect.getValue() + 1);
|
|
18
18
|
ws.send(JSON.stringify({ event: 'start', data: { id: this.client_id } }));
|
|
19
|
-
}), delay(
|
|
19
|
+
}), delay(1), tap(() => !this.$gateway.getValue() && this.$gateway.next({ id: '' })), mergeMap(() => this.#$input), tap(data => ws.send(JSON.stringify(data)))), fromEvent(ws, 'message').pipe(tap((evt) => {
|
|
20
20
|
const e = JSON.parse(evt.data);
|
|
21
21
|
this[`$${e.event}`]?.(e);
|
|
22
22
|
}))).pipe(finalize(() => ws.close()))), retry({ delay: 1000 })).subscribe();
|