SSDNJ
SSDNJ
  • 发布:2024-05-10 16:34
  • 更新:2024-05-10 16:34
  • 阅读:84

#插件讨论# 【 TCPSocket for Android - 雷神震天 】 求解

分类:uni-app
关联插件: TCPSocket for Android

您好,我这边client.write 的内容,通过你的SDK 怎么实现呢?

const net = require('net');
const iconv = require('iconv-lite');
const client = new net.Socket();

client.connect(8888, '192.168.4.1', () => {
console.log('已连接到服务器');
});

let iiii=0;
client.on('data', (buffer) => {
let utf8String = iconv.decode(buffer, 'GBK');
console.log(utf8String); // 输出转换后的UTF-8编码字符串
if(iiii==0){
var gbkStr = iconv.encode('$WLAN:"MaoJu","88889999";"192.168.205.149",12345;\r\n', 'utf8');
console.log(gbkStr);
client.write(gbkStr);
var gbkStr1 = iconv.encode('$WLAN:"MaoJu","88889999*";"192.168.205.149",12345;\r\n', 'GBK');
console.log(gbkStr1);
client.write(gbkStr1);
iiii=1;
}
});
client.on('close', () => {
console.log('连接已关闭');
});

2024-05-10 16:34 负责人:无 分享
已邀请:

要回复问题请先登录注册