我正在与节点js和raspberry pi 3一起使用数据库和其他操作,但是通过套接字通信节点JS不等待响应并运行下一行,并且在响应时仅接收console.log而不向服务器发送任何呼叫。.这是我的
代码func.storeRelayAction(db, "0", decryptedString).then(result => {
console.log("On Store Relay Action : "+ result);
}).then(()=>{
func.getaperioLockConfig(db).then(configs=>{
var net = require('net');
var client = new net.Socket();
client.connect(configs['key_aperio_port'],configs['key_aperio_ip'], function() {
console.log('Connected');
func.getLocMac(db,tokens[2]).then(lock_mac=>{
client.write('Mi-Controller:'+'192.168.1.200'+':'+lock_mac);
this._value = Buffer.from("1", 'utf8');
updateCallback(this,"1");
})
});
client.on('data', function(data) {
console.log('Received: ' + data);
this._value = Buffer.from(data.toString(),
updateCallback(this,data.toString());
client.destroy();
});
})
})