【发布时间】:2016-02-24 08:52:15
【问题描述】:
我正在尝试制作一个聊天应用程序,它将第一条消息发送为“嗨。那里”。 但由于某些原因(可能是不稳定的互联网连接),套接字会被多次初始化并多次发送“Hi.there”消息。下面是代码。如何停止应用发送多条消息?
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.
}
}
});
【问题讨论】:
-
你的客户端代码?
-
这是客户端代码。
标签: node.js sockets socket.io sails.js sails.io.js