@ancon/wildcat-utils 1.50.22 → 1.50.24
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/package.json +1 -1
- package/signalr/SignalR.js +1 -1
- package/signalr/SignalR.mjs +62 -62
- package/signalr/types.d.ts +2 -0
package/package.json
CHANGED
package/signalr/SignalR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var d=(r,e,t)=>e in r?f(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var n=(r,e,t)=>(d(r,typeof e!="symbol"?e+"":e,t),t);const h=require("@microsoft/signalr"),a=require("@ancon/wildcat-types"),l=require("../shared/wait.js"),u=require("../api/generateBackoffWithEqualJitter.js");require("../number/randomIntFromInterval.js");class g{constructor(e){n(this,"internalEvents");n(this,"signalREvents");n(this,"hubConnection");n(this,"clientId");n(this,"logger");n(this,"backoff",[]);n(this,"reconnectAttempt",0);n(this,"shouldReconnect",!0);n(this,"groups");n(this,"info",(e,t)=>{var i;(i=this.logger)==null||i.info(e,t)});n(this,"generateBackoff",()=>{this.backoff=u(50,500,5e3),this.info("Generated new backoff")});n(this,"reconnect",async()=>{if(this.shouldReconnect)try{this.info("Attempting to reconnect...",{attempt:this.reconnectAttempt+1}),await this.connect(!0),this.info("Reconnected"),this.reconnectAttempt=0}catch{if(this.backoff[this.reconnectAttempt]!=null){const t=this.backoff[this.reconnectAttempt];if(t!=null)await l(t);else throw new Error("Could not resolve ms from backoff")}else{this.reconnectAttempt>0&&this.info("Ran out of backoff intervals, restarting backoff..."),this.reconnectAttempt=0,this.generateBackoff();const t=this.backoff[this.reconnectAttempt];if(t!=null)await l(t);else throw new Error("Could not resolve ms from backoff")}this.reconnectAttempt+=1,await this.reconnect()}});n(this,"buildInitialListeners",()=>{this.hubConnection.onclose(()=>{this.groups=[],this.info("Hub connection closed"),this.emitEvent("disconnected"),this.reconnect()}),this.hubConnection.onreconnected(()=>this.emitEvent("reconnected"))});n(this,"emitEvent",(e,...t)=>{if(this.internalEvents.has(e)){this.info(`Emitting event "${e}"`);const i=this.internalEvents.get(e);i&&i.forEach(s=>s(...t))}else this.info(`Failed to emit event "${e}". There were no listeners.`)});n(this,"skipSignal",(e,t)=>{this.info(`Skipped signal "${e}"`,t)});n(this,"enhanceListener",(e,t,i)=>s=>{const o=JSON.parse(s),c=i&&o.clientId&&o.clientId===this.clientId;return c||this.info(`Received signal "${e}"`,s),c?this.skipSignal(e,s):t(o)});n(this,"setClientId",e=>{this.clientId=e});n(this,"connect",async(e=!1)=>{try{this.info("Connecting..."),await this.hubConnection.start(),this.info("Connected"),this.emitEvent("connected")}catch(t){if(this.info("Failed to connect"),e)throw t}});n(this,"disconnect",async()=>{try{this.shouldReconnect=!1,this.info("Disconnecting..."),await this.hubConnection.stop(),this.info("Disconnected"),this.emitEvent("disconnected")}catch{this.info("Failed to disconnect")}});n(this,"addEventListener",(e,t)=>{this.internalEvents.has(e)||this.internalEvents.set(e,[]);const i=this.internalEvents.get(e);return i&&i.push(t),()=>this.removeEventListener(e,t)});n(this,"removeEventListener",(e,t)=>{var i;if(this.internalEvents.has(e)){const s=this.internalEvents.get(e),o=((i=s==null?void 0:s.indexOf)==null?void 0:i.call(s,t))??-1;o>=0?(s.splice(o,1),this.info(`Removed event listener for event "${e}"`)):this.info(`Failed to remove event listener for event "${e}". Specified listener was not found.`)}else this.info(`Failed to remove event listener for event "${e}". Event doesn't have any listeners.`)});n(this,"addSignalListener",(e,t,i=!0)=>{this.signalREvents.has(e)||this.signalREvents.set(e,[]);const s=this.signalREvents.get(e),o=this.enhanceListener(e,t,i);return s&&s.push(o),this.hubConnection.on(e,o),this.info(`Added signal listener for signal "${e}"`),()=>this.removeSignalListener(e,o)});n(this,"removeSignalListener",(e,t)=>{var i;if(this.signalREvents.has(e)){const s=this.signalREvents.get(e),o=((i=s==null?void 0:s.indexOf)==null?void 0:i.call(s,t))??-1;o>=0?(this.hubConnection.off(e,t),s.splice(o,1),this.info(`Removed signal listener for signal "${e}"`)):this.info(`Failed to remove signal listener for signal "${e}". Specified listener was not found.`)}else this.info(`Failed to remove signal listener for signal "${e}". Signal doesn't have any listeners.`)});n(this,"joinGroup",async e=>{this.info(`Joining group "${e}"...`);const t=this.groups.push(e)-1;try{await this.hubConnection.invoke(a.SignalRMethodName.JoinGroup,e),this.info(`Joined group "${e}"`)}catch(i){this.info(`Failed to join group "${e}"`,i),t>=0&&this.groups.splice(t,1)}});n(this,"leaveGroup",async e=>{this.info(`Leaving group "${e}"...`);const t=this.groups.indexOf(e);t>=0&&this.groups.splice(t,1);try{await this.hubConnection.invoke(a.SignalRMethodName.LeaveGroup,e),this.info(`Left group "${e}"`)}catch(i){this.groups.indexOf(e)<0&&this.groups.push(e),this.info(`Failed to leave group "${e}"`,i)}});n(this,"leaveAllGroups",async()=>{this.info(`Leaving all (${this.groups.length}) groups...`);const e=[...this.groups].map(t=>this.leaveGroup(t));await Promise.all(e),this.info("Left all groups")});n(this,"getHubConnectionId",()=>this.hubConnection.connectionId);this.internalEvents=new Map,this.signalREvents=new Map,this.groups=[],e.enableLogging&&(this.logger=e.logger),this.hubConnection=new h.HubConnectionBuilder().withUrl(`${e.signalRApiUrl}/${e.hub}`).configureLogging(h.LogLevel.None).build(),this.buildInitialListeners()}}module.exports=g;
|
|
1
|
+
"use strict";var f=Object.defineProperty;var d=(r,e,t)=>e in r?f(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var n=(r,e,t)=>(d(r,typeof e!="symbol"?e+"":e,t),t);const h=require("@microsoft/signalr"),a=require("@ancon/wildcat-types"),l=require("../shared/wait.js"),u=require("../api/generateBackoffWithEqualJitter.js");require("../number/randomIntFromInterval.js");class g{constructor(e){n(this,"internalEvents");n(this,"signalREvents");n(this,"hubConnection");n(this,"clientId");n(this,"logger");n(this,"backoff",[]);n(this,"reconnectAttempt",0);n(this,"shouldReconnect",!0);n(this,"groups");n(this,"info",(e,t)=>{var i;(i=this.logger)==null||i.info(e,t)});n(this,"generateBackoff",()=>{this.backoff=u(50,500,5e3),this.info("Generated new backoff")});n(this,"reconnect",async()=>{if(this.shouldReconnect)try{this.info("Attempting to reconnect...",{attempt:this.reconnectAttempt+1}),await this.connect(!0),this.info("Reconnected"),this.reconnectAttempt=0}catch{if(this.backoff[this.reconnectAttempt]!=null){const t=this.backoff[this.reconnectAttempt];if(t!=null)await l(t);else throw new Error("Could not resolve ms from backoff")}else{this.reconnectAttempt>0&&this.info("Ran out of backoff intervals, restarting backoff..."),this.reconnectAttempt=0,this.generateBackoff();const t=this.backoff[this.reconnectAttempt];if(t!=null)await l(t);else throw new Error("Could not resolve ms from backoff")}this.reconnectAttempt+=1,await this.reconnect()}});n(this,"buildInitialListeners",()=>{this.hubConnection.onclose(()=>{this.groups=[],this.info("Hub connection closed"),this.emitEvent("disconnected"),this.reconnect()}),this.hubConnection.onreconnected(()=>this.emitEvent("reconnected"))});n(this,"emitEvent",(e,...t)=>{if(this.internalEvents.has(e)){this.info(`Emitting event "${e}"`);const i=this.internalEvents.get(e);i&&i.forEach(s=>s(...t))}else this.info(`Failed to emit event "${e}". There were no listeners.`)});n(this,"skipSignal",(e,t)=>{this.info(`Skipped signal "${e}"`,t)});n(this,"enhanceListener",(e,t,i)=>s=>{const o=JSON.parse(s),c=i&&o.clientId&&o.clientId===this.clientId;return c||this.info(`Received signal "${e}"`,s),c?this.skipSignal(e,s):t(o)});n(this,"setClientId",e=>{this.clientId=e});n(this,"connect",async(e=!1)=>{try{this.info("Connecting..."),await this.hubConnection.start(),this.info("Connected"),this.emitEvent("connected")}catch(t){if(this.info("Failed to connect"),e)throw t}});n(this,"disconnect",async()=>{try{this.shouldReconnect=!1,this.info("Disconnecting..."),await this.hubConnection.stop(),this.info("Disconnected"),this.emitEvent("disconnected")}catch{this.info("Failed to disconnect")}});n(this,"addEventListener",(e,t)=>{this.internalEvents.has(e)||this.internalEvents.set(e,[]);const i=this.internalEvents.get(e);return i&&i.push(t),()=>this.removeEventListener(e,t)});n(this,"removeEventListener",(e,t)=>{var i;if(this.internalEvents.has(e)){const s=this.internalEvents.get(e),o=((i=s==null?void 0:s.indexOf)==null?void 0:i.call(s,t))??-1;o>=0?(s.splice(o,1),this.info(`Removed event listener for event "${e}"`)):this.info(`Failed to remove event listener for event "${e}". Specified listener was not found.`)}else this.info(`Failed to remove event listener for event "${e}". Event doesn't have any listeners.`)});n(this,"addSignalListener",(e,t,i=!0)=>{this.signalREvents.has(e)||this.signalREvents.set(e,[]);const s=this.signalREvents.get(e),o=this.enhanceListener(e,t,i);return s&&s.push(o),this.hubConnection.on(e,o),this.info(`Added signal listener for signal "${e}"`),()=>this.removeSignalListener(e,o)});n(this,"removeSignalListener",(e,t)=>{var i;if(this.signalREvents.has(e)){const s=this.signalREvents.get(e),o=((i=s==null?void 0:s.indexOf)==null?void 0:i.call(s,t))??-1;o>=0?(this.hubConnection.off(e,t),s.splice(o,1),this.info(`Removed signal listener for signal "${e}"`)):this.info(`Failed to remove signal listener for signal "${e}". Specified listener was not found.`)}else this.info(`Failed to remove signal listener for signal "${e}". Signal doesn't have any listeners.`)});n(this,"joinGroup",async e=>{this.info(`Joining group "${e}"...`);const t=this.groups.push(e)-1;try{await this.hubConnection.invoke(a.SignalRMethodName.JoinGroup,e),this.info(`Joined group "${e}"`)}catch(i){this.info(`Failed to join group "${e}"`,i),t>=0&&this.groups.splice(t,1)}});n(this,"leaveGroup",async e=>{this.info(`Leaving group "${e}"...`);const t=this.groups.indexOf(e);t>=0&&this.groups.splice(t,1);try{await this.hubConnection.invoke(a.SignalRMethodName.LeaveGroup,e),this.info(`Left group "${e}"`)}catch(i){this.groups.indexOf(e)<0&&this.groups.push(e),this.info(`Failed to leave group "${e}"`,i)}});n(this,"leaveAllGroups",async()=>{this.info(`Leaving all (${this.groups.length}) groups...`);const e=[...this.groups].map(t=>this.leaveGroup(t));await Promise.all(e),this.info("Left all groups")});n(this,"getHubConnectionId",()=>this.hubConnection.connectionId);this.internalEvents=new Map,this.signalREvents=new Map,this.groups=[],e.enableLogging&&(this.logger=e.logger),this.hubConnection=new h.HubConnectionBuilder().withUrl(`${e.signalRApiUrl}/${e.hub}`).configureLogging(h.LogLevel.None).build(),e.serverTimeoutInMilliseconds&&(this.hubConnection.serverTimeoutInMilliseconds=e.serverTimeoutInMilliseconds),this.buildInitialListeners()}}module.exports=g;
|
package/signalr/SignalR.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var f = Object.defineProperty;
|
|
2
|
-
var l = (r,
|
|
3
|
-
var n = (r,
|
|
2
|
+
var l = (r, e, t) => e in r ? f(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var n = (r, e, t) => (l(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
4
|
import { HubConnectionBuilder as d, LogLevel as u } from "@microsoft/signalr";
|
|
5
5
|
import { SignalRMethodName as h } from "@ancon/wildcat-types";
|
|
6
6
|
import a from "../shared/wait.mjs";
|
|
7
7
|
import g from "../api/generateBackoffWithEqualJitter.mjs";
|
|
8
8
|
import "../number/randomIntFromInterval.mjs";
|
|
9
9
|
class L {
|
|
10
|
-
constructor(
|
|
10
|
+
constructor(e) {
|
|
11
11
|
n(this, "internalEvents");
|
|
12
12
|
n(this, "signalREvents");
|
|
13
13
|
n(this, "hubConnection");
|
|
@@ -17,9 +17,9 @@ class L {
|
|
|
17
17
|
n(this, "reconnectAttempt", 0);
|
|
18
18
|
n(this, "shouldReconnect", !0);
|
|
19
19
|
n(this, "groups");
|
|
20
|
-
n(this, "info", (
|
|
20
|
+
n(this, "info", (e, t) => {
|
|
21
21
|
var i;
|
|
22
|
-
(i = this.logger) == null || i.info(
|
|
22
|
+
(i = this.logger) == null || i.info(e, t);
|
|
23
23
|
});
|
|
24
24
|
n(this, "generateBackoff", () => {
|
|
25
25
|
this.backoff = g(50, 500, 5e3), this.info("Generated new backoff");
|
|
@@ -32,16 +32,16 @@ class L {
|
|
|
32
32
|
}), await this.connect(!0), this.info("Reconnected"), this.reconnectAttempt = 0;
|
|
33
33
|
} catch {
|
|
34
34
|
if (this.backoff[this.reconnectAttempt] != null) {
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
await a(
|
|
35
|
+
const t = this.backoff[this.reconnectAttempt];
|
|
36
|
+
if (t != null)
|
|
37
|
+
await a(t);
|
|
38
38
|
else
|
|
39
39
|
throw new Error("Could not resolve ms from backoff");
|
|
40
40
|
} else {
|
|
41
41
|
this.reconnectAttempt > 0 && this.info("Ran out of backoff intervals, restarting backoff..."), this.reconnectAttempt = 0, this.generateBackoff();
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
await a(
|
|
42
|
+
const t = this.backoff[this.reconnectAttempt];
|
|
43
|
+
if (t != null)
|
|
44
|
+
await a(t);
|
|
45
45
|
else
|
|
46
46
|
throw new Error("Could not resolve ms from backoff");
|
|
47
47
|
}
|
|
@@ -58,30 +58,30 @@ class L {
|
|
|
58
58
|
* @param event Event to emit
|
|
59
59
|
* @param args Arguments to send to the listeners
|
|
60
60
|
*/
|
|
61
|
-
n(this, "emitEvent", (
|
|
62
|
-
if (this.internalEvents.has(
|
|
63
|
-
this.info(`Emitting event "${
|
|
64
|
-
const i = this.internalEvents.get(
|
|
65
|
-
i && i.forEach((s) => s(...
|
|
61
|
+
n(this, "emitEvent", (e, ...t) => {
|
|
62
|
+
if (this.internalEvents.has(e)) {
|
|
63
|
+
this.info(`Emitting event "${e}"`);
|
|
64
|
+
const i = this.internalEvents.get(e);
|
|
65
|
+
i && i.forEach((s) => s(...t));
|
|
66
66
|
} else
|
|
67
|
-
this.info(`Failed to emit event "${
|
|
67
|
+
this.info(`Failed to emit event "${e}". There were no listeners.`);
|
|
68
68
|
});
|
|
69
|
-
n(this, "skipSignal", (
|
|
70
|
-
this.info(`Skipped signal "${
|
|
69
|
+
n(this, "skipSignal", (e, t) => {
|
|
70
|
+
this.info(`Skipped signal "${e}"`, t);
|
|
71
71
|
});
|
|
72
|
-
n(this, "enhanceListener", (
|
|
72
|
+
n(this, "enhanceListener", (e, t, i) => (s) => {
|
|
73
73
|
const o = JSON.parse(s), c = i && o.clientId && o.clientId === this.clientId;
|
|
74
|
-
return c || this.info(`Received signal "${
|
|
74
|
+
return c || this.info(`Received signal "${e}"`, s), c ? this.skipSignal(e, s) : t(o);
|
|
75
75
|
});
|
|
76
|
-
n(this, "setClientId", (
|
|
77
|
-
this.clientId =
|
|
76
|
+
n(this, "setClientId", (e) => {
|
|
77
|
+
this.clientId = e;
|
|
78
78
|
});
|
|
79
|
-
n(this, "connect", async (
|
|
79
|
+
n(this, "connect", async (e = !1) => {
|
|
80
80
|
try {
|
|
81
81
|
this.info("Connecting..."), await this.hubConnection.start(), this.info("Connected"), this.emitEvent("connected");
|
|
82
|
-
} catch (
|
|
83
|
-
if (this.info("Failed to connect"),
|
|
84
|
-
throw
|
|
82
|
+
} catch (t) {
|
|
83
|
+
if (this.info("Failed to connect"), e)
|
|
84
|
+
throw t;
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
n(this, "disconnect", async () => {
|
|
@@ -96,26 +96,26 @@ class L {
|
|
|
96
96
|
* @param event Event to listen on
|
|
97
97
|
* @param listener Event listener function
|
|
98
98
|
*/
|
|
99
|
-
n(this, "addEventListener", (
|
|
100
|
-
this.internalEvents.has(
|
|
101
|
-
const i = this.internalEvents.get(
|
|
102
|
-
return i && i.push(
|
|
99
|
+
n(this, "addEventListener", (e, t) => {
|
|
100
|
+
this.internalEvents.has(e) || this.internalEvents.set(e, []);
|
|
101
|
+
const i = this.internalEvents.get(e);
|
|
102
|
+
return i && i.push(t), () => this.removeEventListener(e, t);
|
|
103
103
|
});
|
|
104
104
|
/**
|
|
105
105
|
* Remove internal event listener
|
|
106
106
|
* @param event Event to stop listening to
|
|
107
107
|
* @param listener Event listener function
|
|
108
108
|
*/
|
|
109
|
-
n(this, "removeEventListener", (
|
|
109
|
+
n(this, "removeEventListener", (e, t) => {
|
|
110
110
|
var i;
|
|
111
|
-
if (this.internalEvents.has(
|
|
112
|
-
const s = this.internalEvents.get(
|
|
113
|
-
o >= 0 ? (s.splice(o, 1), this.info(`Removed event listener for event "${
|
|
114
|
-
`Failed to remove event listener for event "${
|
|
111
|
+
if (this.internalEvents.has(e)) {
|
|
112
|
+
const s = this.internalEvents.get(e), o = ((i = s == null ? void 0 : s.indexOf) == null ? void 0 : i.call(s, t)) ?? -1;
|
|
113
|
+
o >= 0 ? (s.splice(o, 1), this.info(`Removed event listener for event "${e}"`)) : this.info(
|
|
114
|
+
`Failed to remove event listener for event "${e}". Specified listener was not found.`
|
|
115
115
|
);
|
|
116
116
|
} else
|
|
117
117
|
this.info(
|
|
118
|
-
`Failed to remove event listener for event "${
|
|
118
|
+
`Failed to remove event listener for event "${e}". Event doesn't have any listeners.`
|
|
119
119
|
);
|
|
120
120
|
});
|
|
121
121
|
/**
|
|
@@ -123,58 +123,58 @@ class L {
|
|
|
123
123
|
* @param signal Signal name
|
|
124
124
|
* @param listener Signal listener function
|
|
125
125
|
*/
|
|
126
|
-
n(this, "addSignalListener", (
|
|
127
|
-
this.signalREvents.has(
|
|
128
|
-
const s = this.signalREvents.get(
|
|
129
|
-
t,
|
|
126
|
+
n(this, "addSignalListener", (e, t, i = !0) => {
|
|
127
|
+
this.signalREvents.has(e) || this.signalREvents.set(e, []);
|
|
128
|
+
const s = this.signalREvents.get(e), o = this.enhanceListener(
|
|
130
129
|
e,
|
|
130
|
+
t,
|
|
131
131
|
i
|
|
132
132
|
);
|
|
133
|
-
return s && s.push(o), this.hubConnection.on(
|
|
133
|
+
return s && s.push(o), this.hubConnection.on(e, o), this.info(`Added signal listener for signal "${e}"`), () => this.removeSignalListener(e, o);
|
|
134
134
|
});
|
|
135
135
|
/**
|
|
136
136
|
* Remove signal listener
|
|
137
137
|
* @param signal Signal name
|
|
138
138
|
* @param listener Signal listener function
|
|
139
139
|
*/
|
|
140
|
-
n(this, "removeSignalListener", (
|
|
140
|
+
n(this, "removeSignalListener", (e, t) => {
|
|
141
141
|
var i;
|
|
142
|
-
if (this.signalREvents.has(
|
|
143
|
-
const s = this.signalREvents.get(
|
|
144
|
-
o >= 0 ? (this.hubConnection.off(
|
|
145
|
-
`Failed to remove signal listener for signal "${
|
|
142
|
+
if (this.signalREvents.has(e)) {
|
|
143
|
+
const s = this.signalREvents.get(e), o = ((i = s == null ? void 0 : s.indexOf) == null ? void 0 : i.call(s, t)) ?? -1;
|
|
144
|
+
o >= 0 ? (this.hubConnection.off(e, t), s.splice(o, 1), this.info(`Removed signal listener for signal "${e}"`)) : this.info(
|
|
145
|
+
`Failed to remove signal listener for signal "${e}". Specified listener was not found.`
|
|
146
146
|
);
|
|
147
147
|
} else
|
|
148
148
|
this.info(
|
|
149
|
-
`Failed to remove signal listener for signal "${
|
|
149
|
+
`Failed to remove signal listener for signal "${e}". Signal doesn't have any listeners.`
|
|
150
150
|
);
|
|
151
151
|
});
|
|
152
|
-
n(this, "joinGroup", async (
|
|
153
|
-
this.info(`Joining group "${
|
|
154
|
-
const
|
|
152
|
+
n(this, "joinGroup", async (e) => {
|
|
153
|
+
this.info(`Joining group "${e}"...`);
|
|
154
|
+
const t = this.groups.push(e) - 1;
|
|
155
155
|
try {
|
|
156
|
-
await this.hubConnection.invoke(h.JoinGroup,
|
|
156
|
+
await this.hubConnection.invoke(h.JoinGroup, e), this.info(`Joined group "${e}"`);
|
|
157
157
|
} catch (i) {
|
|
158
|
-
this.info(`Failed to join group "${
|
|
158
|
+
this.info(`Failed to join group "${e}"`, i), t >= 0 && this.groups.splice(t, 1);
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
|
-
n(this, "leaveGroup", async (
|
|
162
|
-
this.info(`Leaving group "${
|
|
163
|
-
const
|
|
164
|
-
|
|
161
|
+
n(this, "leaveGroup", async (e) => {
|
|
162
|
+
this.info(`Leaving group "${e}"...`);
|
|
163
|
+
const t = this.groups.indexOf(e);
|
|
164
|
+
t >= 0 && this.groups.splice(t, 1);
|
|
165
165
|
try {
|
|
166
|
-
await this.hubConnection.invoke(h.LeaveGroup,
|
|
166
|
+
await this.hubConnection.invoke(h.LeaveGroup, e), this.info(`Left group "${e}"`);
|
|
167
167
|
} catch (i) {
|
|
168
|
-
this.groups.indexOf(
|
|
168
|
+
this.groups.indexOf(e) < 0 && this.groups.push(e), this.info(`Failed to leave group "${e}"`, i);
|
|
169
169
|
}
|
|
170
170
|
});
|
|
171
171
|
n(this, "leaveAllGroups", async () => {
|
|
172
172
|
this.info(`Leaving all (${this.groups.length}) groups...`);
|
|
173
|
-
const
|
|
174
|
-
await Promise.all(
|
|
173
|
+
const e = [...this.groups].map((t) => this.leaveGroup(t));
|
|
174
|
+
await Promise.all(e), this.info("Left all groups");
|
|
175
175
|
});
|
|
176
176
|
n(this, "getHubConnectionId", () => this.hubConnection.connectionId);
|
|
177
|
-
this.internalEvents = /* @__PURE__ */ new Map(), this.signalREvents = /* @__PURE__ */ new Map(), this.groups = [],
|
|
177
|
+
this.internalEvents = /* @__PURE__ */ new Map(), this.signalREvents = /* @__PURE__ */ new Map(), this.groups = [], e.enableLogging && (this.logger = e.logger), this.hubConnection = new d().withUrl(`${e.signalRApiUrl}/${e.hub}`).configureLogging(u.None).build(), e.serverTimeoutInMilliseconds && (this.hubConnection.serverTimeoutInMilliseconds = e.serverTimeoutInMilliseconds), this.buildInitialListeners();
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
export {
|
package/signalr/types.d.ts
CHANGED