typescript-agi-ipcom 0.0.1 → 0.0.3
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/Channel.js +42 -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) {
|
|
@@ -1029,13 +1047,35 @@ class Channel extends events_1.EventEmitter {
|
|
|
1029
1047
|
});
|
|
1030
1048
|
});
|
|
1031
1049
|
}
|
|
1050
|
+
/*
|
|
1051
|
+
private async sendCommand(command: string): Promise<IResponse> {
|
|
1052
|
+
return new Promise(async (resolve) => {
|
|
1053
|
+
this.once('response', (response: IResponse) => {
|
|
1054
|
+
return resolve(response);
|
|
1055
|
+
});
|
|
1056
|
+
|
|
1057
|
+
await this.send(format('%s\n',
|
|
1058
|
+
command.trim(),
|
|
1059
|
+
));
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
*/
|
|
1032
1063
|
sendCommand(command) {
|
|
1033
1064
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1034
|
-
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
1065
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
1066
|
+
// Verificar se a conexão ainda está ativa
|
|
1067
|
+
if (!this.m_connection || this.m_connection.destroyed) {
|
|
1068
|
+
return reject(new Error('Stream has been destroyed'));
|
|
1069
|
+
}
|
|
1035
1070
|
this.once('response', (response) => {
|
|
1036
1071
|
return resolve(response);
|
|
1037
1072
|
});
|
|
1038
|
-
|
|
1073
|
+
try {
|
|
1074
|
+
yield this.send(util_1.format('%s\n', command.trim()));
|
|
1075
|
+
}
|
|
1076
|
+
catch (err) {
|
|
1077
|
+
return reject(err);
|
|
1078
|
+
}
|
|
1039
1079
|
}));
|
|
1040
1080
|
});
|
|
1041
1081
|
}
|