@ipcom/asterisk-ari 0.0.103 → 0.0.105

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.
@@ -1947,8 +1947,10 @@ var WebSocketClient = class extends import_events4.EventEmitter {
1947
1947
  try {
1948
1948
  const decodedData = JSON.parse(rawData.toString());
1949
1949
  if (decodedData?.type && decodedData?.application) {
1950
+ console.log({ handleMessage: decodedData });
1951
+ const scopedEvent = `${decodedData.application}:${decodedData.type}`;
1952
+ this.emit(scopedEvent, decodedData);
1950
1953
  this.emit(decodedData.application, decodedData);
1951
- this.emit("message", decodedData);
1952
1954
  } else {
1953
1955
  console.warn(
1954
1956
  "Mensagem recebida sem tipo ou aplica\xE7\xE3o v\xE1lida:",
@@ -2071,7 +2073,7 @@ var AriClient = class {
2071
2073
  console.log(
2072
2074
  `Registrando listener para evento '${eventType}' no app '${app}'.`
2073
2075
  );
2074
- const callbackKey = `${eventType}-${app}`;
2076
+ const callbackKey = `${app}:${eventType}`;
2075
2077
  if (this.eventListeners.has(callbackKey)) {
2076
2078
  console.log(
2077
2079
  `Listener para evento '${eventType}' j\xE1 est\xE1 registrado no app '${app}'. Ignorando duplicata.`
@@ -2094,7 +2096,8 @@ var AriClient = class {
2094
2096
  };
2095
2097
  const wsClient = this.wsClients.get(app);
2096
2098
  if (wsClient) {
2097
- wsClient.on(eventType, wrappedCallback);
2099
+ const scopedEvent = `${app}:${eventType}`;
2100
+ wsClient.on(scopedEvent, wrappedCallback);
2098
2101
  this.eventListeners.set(callbackKey, wrappedCallback);
2099
2102
  console.log(
2100
2103
  `Listener para evento '${eventType}' registrado com sucesso no app '${app}'.`