typescript-agi-ipcom 0.0.2 → 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 +24 -2
- package/package.json +1 -1
package/dist/Channel.js
CHANGED
|
@@ -1047,13 +1047,35 @@ class Channel extends events_1.EventEmitter {
|
|
|
1047
1047
|
});
|
|
1048
1048
|
});
|
|
1049
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
|
+
*/
|
|
1050
1063
|
sendCommand(command) {
|
|
1051
1064
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1052
|
-
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
|
+
}
|
|
1053
1070
|
this.once('response', (response) => {
|
|
1054
1071
|
return resolve(response);
|
|
1055
1072
|
});
|
|
1056
|
-
|
|
1073
|
+
try {
|
|
1074
|
+
yield this.send(util_1.format('%s\n', command.trim()));
|
|
1075
|
+
}
|
|
1076
|
+
catch (err) {
|
|
1077
|
+
return reject(err);
|
|
1078
|
+
}
|
|
1057
1079
|
}));
|
|
1058
1080
|
});
|
|
1059
1081
|
}
|