代码拉取完成,页面将自动刷新
同步操作将从 大菜卵/Aircontroller-scrcpy 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
function connectDevice(deviceId) {
if (app.connectMap[deviceId]) {
try {
app.connectMap[deviceId].end();
} catch (error) {
}
}
var buf = '';
var contentLength = 0;
app.devices[deviceId].source = "123";
try {
var _client = net.connect(
{
port: app.devices[deviceId].port, host: '127.0.0.1'
}, function (err) {
app.connectMap[deviceId] = _client;
if (err) {
console.log('connect socket server error');
app.connectMap[deviceId] = null;
return;
}
_client.on('data', function (msg) {
// _client.end()
if (msg.length > 10) {
buf += msg;
if (buf.length == contentLength) {
if (app.screensMap[deviceId] == null) {
return;
}
try {
app.screens[app.screensMap[deviceId]].source = buf;
} catch (error) {
console.debug(app.screens[app.screensMap[deviceId]])
}
app.screens[app.screensMap[deviceId]].source = buf;
buf = null;
}
}
else {
buf = 'data:image/jpeg;base64,'
contentLength = parseInt(msg) + 23;
}
})
_client.on('error', function (err) {
console.error("连接失败:重试");
setTimeout(() => {
if (app.devices[deviceId]) {
connectDevice(deviceId);
} else {
app.connectMap[deviceId] = null;
}
}, 10000);
})
_client.on('timeout', function (err) {
console.error("连接超时:重试");
setTimeout(() => {
if (app.devices[deviceId]) {
connectDevice(deviceId);
} else {
app.connectMap[deviceId] = null;
}
}, 10000);
})
_client.on('connect', function (err) {
console.log("连接设备成功");
app.connectMap[deviceId] = _client;
})
})
} catch (error) {
console.error(error);
console.error("连接失败:重试");
setTimeout(() => {
if (app.devices[deviceId]) {
connectDevice(deviceId);
} else {
app.connectMap[deviceId] = null;
}
}, 10000);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。