Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangWei-KUMO committed Dec 10, 2024
1 parent b24e3df commit c5c9da6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,13 @@ export async function prepareBot() {
bot.on('scan', (qrcode) => {
// 生成微信登录二维码
qrcodeToTerminal(qrcode);
wss.on('connection', (ws) => {
ws.on('close', () => {
console.log('客户端失去连接');
});
console.log("发送二维码")
ws.send(qrcode);

wss.clients.forEach((client) => {
console.log("发送二维码",client)

if (client.readyState === WebSocket.OPEN) { // Ensure the client is open
client.send(qrcode);
}
});
})

Expand All @@ -286,6 +287,9 @@ export async function prepareBot() {
return console.error(error);
}
});
wss.clients.forEach((client) => {
client.close(); // Important: Close client after login
});
})

bot.on("error", (e) => {
Expand Down

0 comments on commit c5c9da6

Please sign in to comment.