I have some URL(number of URL can vary) whom i want to ping using socket.io one after the other.Means receiving ping of first url, then request of second.
(我有一些URL(URL的数量可以变化),我想一个接一个地使用socket.io进行ping。这意味着先接收第一个url的ping,然后接收第二个url的ping。)
var okPing=[];
for(let i=0;i<urls.length;i++){
let temp_socket=io.connect(urls[i]);
checkPing(temp_socket);
checkPong(temp_socket);//How to wait for pong here?It will not get response in the same order
temp_soc.disconnect();
temp_soc.close();
temp_soc=null;
}
function checkPing(socket){
startPingTime = Date.now();
socket.emit('pingcheck');
}
function checkPong(socket){
socket.on('pongcheck');
}
What to do to get the response in order of execution?
(如何执行才能获得响应?)
ask by JustStarted translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…