typescript-agi-ipcom 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. package/dist/Channel.js +18 -0
  2. package/package.json +1 -1
package/dist/Channel.js CHANGED
@@ -1016,9 +1016,27 @@ class Channel extends events_1.EventEmitter {
1016
1016
  };
1017
1017
  this.emit('response', response);
1018
1018
  }
1019
+ /*
1020
+ private async send(message: string): Promise<void> {
1021
+ return new Promise((resolve, reject) => {
1022
+ this.emit('send', message);
1023
+ this.m_connection.write(message, (error) => {
1024
+ if (error) {
1025
+ return reject(error);
1026
+ }
1027
+ return resolve();
1028
+ });
1029
+ });
1030
+ }
1031
+ */
1032
+ // Modificado para testes
1019
1033
  send(message) {
1020
1034
  return __awaiter(this, void 0, void 0, function* () {
1021
1035
  return new Promise((resolve, reject) => {
1036
+ // Verificar se a conexão ainda está ativa
1037
+ if (!this.m_connection || this.m_connection.destroyed) {
1038
+ return reject(new Error('Stream has been destroyed'));
1039
+ }
1022
1040
  this.emit('send', message);
1023
1041
  this.m_connection.write(message, (error) => {
1024
1042
  if (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typescript-agi-ipcom",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "NodeJS TypeScript Library for Asterisk AGI Interfaces",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",