0
我正在尝试制作一个聊天应用程序,它将第一条消息发送为“Hi。there”。 但由于某些原因(不稳定的互联网连接可能是一个),套接字会多次初始化并多次发送“Hi。there”消息。以下是代码。如何停止发送多条消息的应用程序?阻止Socket连接再次初始化
io.socket.on('connect', function() {
/* On successfull connection to server */
console.log('Connected to server');
//Some code here
io.socket.get(url + '/userstatus/subscribe', function(resData, jwres) {
//Some code here
io.socket.on("userstatus", function(event) {
//Socket updartes
// Send Message code at this line.
}
}
});
你的客户端代码? – sdg
这是客户端代码。 –