@ipcom/asterisk-ari 0.0.74 → 0.0.75
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/dist/cjs/index.cjs +12 -15
- package/dist/cjs/index.cjs.map +3 -3
- package/dist/esm/index.js +12 -15
- package/dist/esm/index.js.map +3 -3
- package/dist/types/ari-client/ariClient.d.ts.map +1 -1
- package/dist/types/ari-client/resources/channels.d.ts +0 -5
- package/dist/types/ari-client/resources/channels.d.ts.map +1 -1
- package/dist/types/ari-client/utils.d.ts +7 -1
- package/dist/types/ari-client/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -287,12 +287,21 @@ function toQueryParams2(options) {
|
|
|
287
287
|
Object.entries(options).filter(([, value]) => value !== void 0).map(([key, value]) => [key, value])
|
|
288
288
|
).toString();
|
|
289
289
|
}
|
|
290
|
-
function isChannelEvent(event) {
|
|
291
|
-
|
|
290
|
+
function isChannelEvent(event, channelId) {
|
|
291
|
+
const hasChannel = "channel" in event && event.channel?.id !== void 0;
|
|
292
|
+
const matchesChannelId = hasChannel && (!channelId || event.channel?.id === channelId);
|
|
293
|
+
if (!hasChannel || channelId && !matchesChannelId) {
|
|
294
|
+
console.log(
|
|
295
|
+
`Evento ignorado no isChannelEvent: tipo=${event.type}, canal esperado=${channelId}, evento recebido=`,
|
|
296
|
+
event
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
return matchesChannelId;
|
|
292
300
|
}
|
|
293
301
|
|
|
294
302
|
// src/ari-client/resources/channels.ts
|
|
295
303
|
var ChannelInstance = class extends EventEmitter2 {
|
|
304
|
+
// ID do canal
|
|
296
305
|
constructor(client, baseClient, channelId = `channel-${Date.now()}`) {
|
|
297
306
|
super();
|
|
298
307
|
this.client = client;
|
|
@@ -309,7 +318,7 @@ var ChannelInstance = class extends EventEmitter2 {
|
|
|
309
318
|
);
|
|
310
319
|
}
|
|
311
320
|
wsClient.on("message", (event) => {
|
|
312
|
-
if (
|
|
321
|
+
if (isChannelEvent(event)) {
|
|
313
322
|
console.log(`Evento recebido no ChannelInstance: ${event.type}`, event);
|
|
314
323
|
this.emit(event.type, event);
|
|
315
324
|
}
|
|
@@ -317,18 +326,6 @@ var ChannelInstance = class extends EventEmitter2 {
|
|
|
317
326
|
}
|
|
318
327
|
channelData = null;
|
|
319
328
|
id;
|
|
320
|
-
// ID do canal
|
|
321
|
-
/**
|
|
322
|
-
* Verifica se o evento possui a propriedade `channel`.
|
|
323
|
-
* @param event Evento recebido.
|
|
324
|
-
*/
|
|
325
|
-
isChannelEvent(event) {
|
|
326
|
-
const isChannelEvent2 = event && typeof event === "object" && "channel" in event && event.channel?.id === this.channelId;
|
|
327
|
-
if (!isChannelEvent2) {
|
|
328
|
-
console.log(`Evento ignorado no ChannelInstance: ${event.type}`, event);
|
|
329
|
-
}
|
|
330
|
-
return isChannelEvent2;
|
|
331
|
-
}
|
|
332
329
|
/**
|
|
333
330
|
* Adiciona um listener para eventos de canal.
|
|
334
331
|
*/
|